Vern, your mail host has banned the domain gmx.de, so I try it this way :)

Subj.: Prob with 16550A


> The speeds of 16450 and 8250 are not supported by the UARTs.  I don't
??

> know what you mean by 'manually set ...'.  Only the speeds defined in
> the 'termios(7)' manual page are supported by Linux.
manually: setserial /dev/ttyS0 uart 16450   :-)

> 
> Read my 'serial_suite.tgz'.  This is a collection of blurbs about the
> care and feeding of the serial ports and some simple programs.  There is
Of course already done ;-)

> a file demonstrating how the lock files should be programmed. There
> is a simple getty, a dialer for ppp connections and some other misc
> programs.
But only stuff dealing with a modem.

Here is a snip of my code. It follows the Serial-Programming-HOWTO,
synchronous non-canonical mode.
Please ignore the german comments.

 memset(&Newtio,0x00,sizeof(Newtio));
 Newtio.c_cflag=CS8|CREAD; // tried: CLOCAL, CRTSCTS
 Newtio.c_iflag=0; // tried: IGNPAR and most other :(
 Newtio.c_oflag=0;
 Newtio.c_lflag=0;
 Newtio.c_cc[VTIME]=0; // 100; wait max 10 seconds; doesnt work?
 Newtio.c_cc[VMIN]=KS20CommLength; // KS20CommLength; // _blocking_ read until >=17 
chars received
 cfsetospeed(&Newtio,BAUDRATE);
 cfsetispeed(&Newtio,BAUDRATE);

 struct termios Oldtio;
 int fd,res,u,os;
 // KS20Kommando ksCmd;
 unsigned char retString[100];
 unsigned char vString[KS20CommLength+1];
 sighandler_t oldhandler;

 if((oldhandler=signal(SIGINT,tschau))==SIG_ERR) {
  fprintf(stderr,"Kann Signalhandler 'tschau' nicht einrichten.\n");
  return(-1);
 }

 if(makeValidKS20Command(cString,ksCmd)!=0) exit(-1);
 makeCheckSum(ksCmd);
 if(serializeKS20Command(ksCmd,vString)!=0) exit(-1);  
 vString[KS20CommLength]=0x00; // useless
 fprintf(stderr,"Write to %s:\n",Device);
 for(res=0;res<KS20CommLength;++res)
  fprintf(stderr," %02X",vString[res]);

 while(sigint_caught==0) {
  fd=open(Device,O_RDWR|O_NOCTTY); // serielles Device oeffnen
  if(fd<0) {
   perror(Device); exit(-1);
  }
  tcgetattr(fd,&Oldtio); // alte Einstellungen speichern
  tcflush(fd,TCIFLUSH); // get rid of garbage
  tcsetattr(fd,TCSANOW,&Newtio);
  res=write(fd,vString,KS20CommLength); // KS20 command length = 17
  if(res!=KS20CommLength) {
   fprintf(stderr,"\nwrite breaks after %i chars.",res); close(fd);
   exit(-1);
  }
  fprintf(stderr," ... OK\n");
  sleep(3);
  res=read(fd,retString,100); // should return after KS20CommLength chars read
  retString[res]=0x00;
  fprintf(stderr,"Read %i Bytes:\n",res);
  if(res>18)    // because there is a loop-back
   os=18;       // offset
  else os=0;
  if(!memcmp(vString,retString,19)) // KS20Commlength+0D0A; 
   for(u=0;u<os;++u)
    fprintf(stderr," %02X",retString[u]);
    
  for(u=os;u<res;++u)
   fprintf(stderr," %02X",retString[u]);
  if(res<17) {
   fprintf(stderr,"...NOT OK! Terminating.\n");
   return(-1);
  }
  retString[res-2]=0x00;    // 2 Bytes garbage
  if(!checkKS20CommandValid(&(retString[os]))) {
   perror("Returnierter Befehl nicht gueltig"); close(fd); exit(-1);
  }

  // Ende der Routine
  tcsetattr(fd,TCSANOW,&Oldtio);
  close(fd);
  // returnierte daten zur weiteren auswertung in struktur eintragen
  strncpy(ksCmd->data,&(retString[os+7]),KS20DataLength);
  if(poll==0) break;
  sleep(poll);
 
I had a discussion with Niclas Hedhman about my problem. Here is a summary
(Niclas is quoted):

\begin{summary}
> You don't have a RS485<->RS232 converter, but a RS422/423 <-> RS232 converter,
In fact it is a noname V.24/RS232 <-> RS422/RS485 converter. There are
some (2) dip-switches on it, but documentation is poor :(
 
As mentioned in my last mail, the converter has four connections, two for
transmitting and two for receiving, so the converter don't need to switch
direction (I think the converter is simply a MAX 232 and a SN 75179). The
controller device has only the T+ & T- connection, so it seems to
change the direction. To join the two things I connected the converter's T's
to the converter R's and of course to the device's T's. My code therefore
has to discard 17 Bytes (+ 2 (0xAA0xFF) added by converter or C550).

> And it is NOT a matter of connecting T to R and everything would be fine. The
> Transmit
> port must be Inactivated during reception. Otherwise both the Transmit port on
> the
> converter AND the transmit port on the device will be driving the RS485 segment
> at the
> same time.
But why does it work on a C450???? 

> Possibly electrical or timing differences. When the device and the T port is both
> driving the segment, you will end up with non-conformant signal streams
> and the two chips are interpreting it differently. I agree that it sounds very
> strange that the 450 get anything useful out of it.


-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to [EMAIL PROTECTED]

Reply via email to