> My suggestion is to simply short pins 2-3 on the DB-9 and see if you get
> characters echoed.  If you do not, then it is likely your cable is
> wrong.  Try shorting TD and RD on the IDC10 header directly on the board
> and try the same thing.  If that doesn't work, then it is clearly not
> your cable.
> 

Great suggestions everyone!  We're definitely getting closer.  Indeed I am 
certain the wiring is correct; that was one of the first things I checked.  
Instead, this is looking more like an OpenBSD configuration or hardware 
issue.  For example, if I jumper TX and RX together on the IDC10 header as 
suggested above and run a simple loopback program (listed below), I receive 0 
bytes back on the read. 

This program displays both 9600 for the old and new rates.

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

#define BAUDRATE B9600
#define MODEMDEVICE "/dev/cua01"
#define _POSIX_SOURCE 1 /* POSIX compliant source */
#define FALSE 0
#define TRUE 1

int main(int argc, char **argv)
{
        unsigned char serialbuf[512];
        int fd, resume;
        struct termios oldtio, newtio;

        int n = 0;
        char m[20]="test\r\n";

        // Open serial port for communications
        fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY | O_NDELAY);
        if (fd < 0)
        {
                perror(MODEMDEVICE);
                exit(-1);
        }
        else
        {
                printf("\nSerial Port Initializing...\n\n");
        }

        // Save existing port settings
        tcgetattr(fd, &oldtio);
        bzero(&newtio, sizeof(newtio));

        /*
         CRTSCTS : flow control
         CS8     : 8N1
         CLOCAL  : local connection, no modem contol
         CREAD   : enable receiving characters
        */
        newtio.c_cflag = BAUDRATE | CS8 | CLOCAL | CREAD | CRTSCTS;
        printf("\nOld Rate = %d\n", cfgetispeed(&oldtio));

        newtio.c_iflag = IGNPAR;
        newtio.c_oflag = 0;
        newtio.c_lflag = 0;

        // Activate settings
        tcflush(fd, TCIFLUSH);
        fcntl(fd, F_SETFL, 0);
        tcsetattr(fd,TCSANOW,&newtio);
        cfsetispeed(&newtio, B9600);
        cfsetospeed(&newtio, B9600);
        printf("New Rate = %d\n", cfgetispeed(&newtio));

        // Begin Receiving serial data communication
        printf("\nReceiving on Serial Port...\n");

        write(fd, m, strlen(m));
        usleep(5000000);
        fcntl(fd, F_SETFL, FNDELAY);
        resume = read(fd,serialbuf,512);
        if (resume >= 0)
        {
           printf("Size: %d\n", resume);
           for (n=0; n<resume; n++)
             printf("%c\n",serialbuf[n]);
        }
        else
        {
           printf("SERIAL read error %d %s\n", errno, strerror(errno));
        }


        tcsetattr(fd, TCSANOW, &oldtio);
        return 0;
}


The x's below denotes the two pins jumpered on JP11, where the JP11 label is 
directly adjacent to pin 1 on the IDC10.
JP11
+------+
| .  . |
| x  . |
| x  . |
| .  . |
| .  . |
+------+


And just for completion to show that the com ports are believed to be set 
correctly...

/etc/boot.conf:
stty com0 9600
set tty com0

I'm not entirely certain of how OpenBSD differentiates the tty and cua devices 
so I'll also include /etc/ttys.

/etc/ttys:
# name  getty                           type    status          comments
#
console "/usr/libexec/getty std.9600"   vt220   on  secure
ttyC0   "/usr/libexec/getty std.9600"   vt220   on  secure
ttyC1   "/usr/libexec/getty std.9600"   vt220   on  secure
ttyC2   "/usr/libexec/getty std.9600"   vt220   on  secure
ttyC3   "/usr/libexec/getty std.9600"   vt220   on  secure
ttyC4   "/usr/libexec/getty std.9600"   vt220   off secure
ttyC5   "/usr/libexec/getty std.9600"   vt220   off secure
ttyC6   "/usr/libexec/getty std.9600"   vt220   off secure
ttyC7   "/usr/libexec/getty std.9600"   vt220   off secure
ttyC8   "/usr/libexec/getty std.9600"   vt220   off secure
ttyC9   "/usr/libexec/getty std.9600"   vt220   off secure
ttyCa   "/usr/libexec/getty std.9600"   vt220   off secure
ttyCb   "/usr/libexec/getty std.9600"   vt220   off secure
tty00   "/usr/libexec/getty std.9600"   vt220   on  secure
tty01   "/usr/libexec/getty std.9600"   unknown off
tty02   "/usr/libexec/getty std.9600"   unknown off
tty03   "/usr/libexec/getty std.9600"   unknown off
tty04   "/usr/libexec/getty std.9600"   unknown off
tty05   "/usr/libexec/getty std.9600"   unknown off
tty06   "/usr/libexec/getty std.9600"   unknown off
tty07   "/usr/libexec/getty std.9600"   unknown off
...

Thanks again,

Greg



_______________________________________________
Soekris-tech mailing list
[email protected]
http://lists.soekris.com/mailman/listinfo/soekris-tech

Reply via email to