EmbeddedRelated.com
Forums
Memfault Beyond the Launch

LED Display

Started by ratemonotonic September 6, 2007
Hi All,

I am working with a big LED display which interfaces with the PC by
RS232 (9600 baud,no parity , 2 stop bits , 8 bit, no hardware flow
control ).
I am trying to write my own application using cygwin on vista using
open , read and write function calls. Every thing works data is
comming out of com2 but is not read by the LED display ,
I have written a basic programm which sends data to the LED display
this works. I think it is something to do with the way I configure the
serial port, can anyone check my code to initialise the port -

s->connected=0; /* reset in case we fail to connect | O_NOCTTY */

	      s->fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NDELAY);
	      if (s->fd == -1) return 0;
	      else fcntl(s->fd, F_SETFL, FASYNC);

	      //fcntl(s->fd, F_SETFL, 0);

	      tcgetattr(s->fd, &options);

	      /* go to 9600 baud */
	      cfsetispeed(&options, B9600);
	      cfsetospeed(&options, B9600);

	      options.c_cflag |= (CLOCAL | CREAD); /* enable */

	      options.c_cflag &= ~PARENB; /* 8N1 */
	      options.c_cflag |= CSTOPB;
	      options.c_cflag &= ~CSIZE;
	      options.c_cflag |= CS8;
	      //options.tcflag_t |= CIGNORE ;
	      options.c_cflag &= ~CRTSCTS;
	      options.c_cflag &= ~CRTSXOFF;


	      /* set all of the options */
	      tcsetattr(s->fd, TCSANOW, &options);

	      s->connected=1;
	      return 1;

the other thing could be the serial cable and DTE -DCE set up I have
ruled it out by testing with TX connected with RX of the LED display
and vice versa.
ANy help is appreciated.
thanks
Rate

"ratemonotonic" <niladri1979@gmail.com> wrote in message 
news:1189087077.141997.227930@50g2000hsm.googlegroups.com...
> Hi All, > > I am working with a big LED display which interfaces with the PC by > RS232 (9600 baud,no parity , 2 stop bits , 8 bit, no hardware flow > control ). > I am trying to write my own application using cygwin on vista using > open , read and write function calls. Every thing works data is > comming out of com2 but is not read by the LED display , > I have written a basic programm which sends data to the LED display > this works. I think it is something to do with the way I configure the > serial port, can anyone check my code to initialise the port - > > s->connected=0; /* reset in case we fail to connect | O_NOCTTY */ > > s->fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NDELAY); > if (s->fd == -1) return 0; > else fcntl(s->fd, F_SETFL, FASYNC); > > //fcntl(s->fd, F_SETFL, 0); > > tcgetattr(s->fd, &options); > > /* go to 9600 baud */ > cfsetispeed(&options, B9600); > cfsetospeed(&options, B9600); > > options.c_cflag |= (CLOCAL | CREAD); /* enable */ > > options.c_cflag &= ~PARENB; /* 8N1 */ > options.c_cflag |= CSTOPB; > options.c_cflag &= ~CSIZE; > options.c_cflag |= CS8; > //options.tcflag_t |= CIGNORE ; > options.c_cflag &= ~CRTSCTS; > options.c_cflag &= ~CRTSXOFF; > > > /* set all of the options */ > tcsetattr(s->fd, TCSANOW, &options); > > s->connected=1; > return 1; > > the other thing could be the serial cable and DTE -DCE set up I have > ruled it out by testing with TX connected with RX of the LED display > and vice versa. > ANy help is appreciated. > thanks > Rate >
Can it be CTS RTS need connecting?
On Sep 6, 4:13 pm, "TT_Man" <Some...@ntlworld.com> wrote:
> "ratemonotonic" <niladri1...@gmail.com> wrote in message > > news:1189087077.141997.227930@50g2000hsm.googlegroups.com... > > > > > Hi All, > > > I am working with a big LED display which interfaces with the PC by > > RS232 (9600 baud,no parity , 2 stop bits , 8 bit, no hardware flow > > control ). > > I am trying to write my own application using cygwin on vista using > > open , read and write function calls. Every thing works data is > > comming out of com2 but is not read by the LED display , > > I have written a basic programm which sends data to the LED display > > this works. I think it is something to do with the way I configure the > > serial port, can anyone check my code to initialise the port - > > > s->connected=0; /* reset in case we fail to connect | O_NOCTTY */ > > > s->fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NDELAY); > > if (s->fd == -1) return 0; > > else fcntl(s->fd, F_SETFL, FASYNC); > > > //fcntl(s->fd, F_SETFL, 0); > > > tcgetattr(s->fd, &options); > > > /* go to 9600 baud */ > > cfsetispeed(&options, B9600); > > cfsetospeed(&options, B9600); > > > options.c_cflag |= (CLOCAL | CREAD); /* enable */ > > > options.c_cflag &= ~PARENB; /* 8N1 */ > > options.c_cflag |= CSTOPB; > > options.c_cflag &= ~CSIZE; > > options.c_cflag |= CS8; > > //options.tcflag_t |= CIGNORE ; > > options.c_cflag &= ~CRTSCTS; > > options.c_cflag &= ~CRTSXOFF; > > > /* set all of the options */ > > tcsetattr(s->fd, TCSANOW, &options); > > > s->connected=1; > > return 1; > > > the other thing could be the serial cable and DTE -DCE set up I have > > ruled it out by testing with TX connected with RX of the LED display > > and vice versa. > > ANy help is appreciated. > > thanks > > Rate > > Can it be CTS RTS need connecting?- Hide quoted text - > > - Show quoted text -
The LED display doesnt support Hardware flow control. The basic program I wrote works without flow control as well , I cant figgure out anything diffrent between the logic of the basic program and the c program
On 6 Sep, 14:57, ratemonotonic <niladri1...@gmail.com> wrote:
> Hi All, > > I am working with a big LED display which interfaces with the PC by > RS232 (9600 baud,no parity , 2 stop bits , 8 bit, no hardware flow > control ). > I am trying to write my own application using cygwin on vista using > open , read and write function calls. Every thing works data is > comming out of com2 but is not read by the LED display , > I have written a basic programm which sends data to the LED display > this works. I think it is something to do with the way I configure the > serial port, can anyone check my code to initialise the port - > > s->connected=0; /* reset in case we fail to connect | O_NOCTTY */ > > s->fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NDELAY); > if (s->fd == -1) return 0; > else fcntl(s->fd, F_SETFL, FASYNC); > > //fcntl(s->fd, F_SETFL, 0); > > tcgetattr(s->fd, &options); > > /* go to 9600 baud */ > cfsetispeed(&options, B9600); > cfsetospeed(&options, B9600); > > options.c_cflag |= (CLOCAL | CREAD); /* enable */ > > options.c_cflag &= ~PARENB; /* 8N1 */ > options.c_cflag |= CSTOPB; > options.c_cflag &= ~CSIZE; > options.c_cflag |= CS8; > //options.tcflag_t |= CIGNORE ; > options.c_cflag &= ~CRTSCTS; > options.c_cflag &= ~CRTSXOFF; > > /* set all of the options */ > tcsetattr(s->fd, TCSANOW, &options); > > s->connected=1; > return 1; > > the other thing could be the serial cable and DTE -DCE set up I have > ruled it out by testing with TX connected with RX of the LED display > and vice versa. > ANy help is appreciated. > thanks > Rate
According to your comment - /* (8N1)*/ - you are setting it up for a single stop bit. Is this what you intend? You said 2 at the start... Cheers TW
ratemonotonic wrote:
>>=20 >>> options.c_cflag &=3D ~PARENB; /* 8N1 */ >>> options.c_cflag |=3D CSTOPB; >>> options.c_cflag &=3D ~CSIZE; >>> options.c_cflag |=3D CS8; >>> //options.tcflag_t |=3D CIGNORE ; >>> options.c_cflag &=3D ~CRTSCTS; >>> options.c_cflag &=3D ~CRTSXOFF; >>=20 >=20 > The LED display doesnt support Hardware flow control. The basic > program I wrote works without flow control as well , I cant figgure > out anything diffrent between the logic of the basic program and the c > program
At one point you say "2 stop bits", but your comment here indicates 1 = stop bit. I don't know anything about your platform so I can't say = whether your comments or your code are in error, but they do differ. 8N2 is an unusual requirement. --=20 Jim
On 6 Sep, 17:58, "Jim Mack" <jm...@mdxi.nospam.com> wrote:
> ratemonotonic wrote: > > >>> options.c_cflag &= ~PARENB; /* 8N1 */ > >>> options.c_cflag |= CSTOPB; > >>> options.c_cflag &= ~CSIZE; > >>> options.c_cflag |= CS8; > >>> //options.tcflag_t |= CIGNORE ; > >>> options.c_cflag &= ~CRTSCTS; > >>> options.c_cflag &= ~CRTSXOFF; > > > The LED display doesnt support Hardware flow control. The basic > > program I wrote works without flow control as well , I cant figgure > > out anything diffrent between the logic of the basic program and the c > > program > > At one point you say "2 stop bits", but your comment here indicates 1 stop bit. I don't know anything about your platform so I can't say whether your comments or your code are in error, but they do differ. > > 8N2 is an unusual requirement. > > -- > Jim
Hi , I Agree it is an odd requirement , but with my basic programe it works with both 2 and 1 stop bit. and it doesnt work with the C programme with both the settings. Sorry I should have mentioned that. My platform is cygwin running on vista. Thanks Niladri
If you don't especially need UNIX compatibility, remember that another easy 
way to interface to the serial port is to use any of the .NET languages (C#, 
Visual Basic), version 2005 or later.  There is a free "Express" C# 
development system.


Jim Mack wrote:
>
... snip ...
> > At one point you say "2 stop bits", but your comment here indicates > 1 stop bit. I don't know anything about your platform so I can't say > whether your comments or your code are in error, but they do differ. > > 8N2 is an unusual requirement.
If you use it only for transmission you gain a bit on the clock accuracy required, at the cost of transmission speed. Please don't exceed 72 chars in transmitted lines. 67 is better. -- Chuck F (cbfalconer at maineline dot net) Available for consulting/temporary embedded and systems. <http://cbfalconer.home.att.net> -- Posted via a free Usenet account from http://www.teranews.com
ratemonotonic wrote:
> Hi All, > > I am working with a big LED display which interfaces with the PC by > RS232 (9600 baud,no parity , 2 stop bits , 8 bit, no hardware flow > control ). > I am trying to write my own application using cygwin on vista using > open , read and write function calls. Every thing works data is > comming out of com2 but is not read by the LED display , > I have written a basic programm which sends data to the LED display > this works.
You have a big advantage -- a working system to compare against. Monitor all the lines and compare what the Basic program is sending and what your other application is sending. Try to mimic the working signals in your second program. -- Thad
On 7 Sep, 04:04, Thad Smith <ThadSm...@acm.org> wrote:
> ratemonotonic wrote: > > Hi All, > > > I am working with a big LED display which interfaces with the PC by > > RS232 (9600 baud,no parity , 2 stop bits , 8 bit, no hardware flow > > control ). > > I am trying to write my own application using cygwin on vista using > > open , read and write function calls. Every thing works data is > > comming out of com2 but is not read by the LED display , > > I have written a basic programm which sends data to the LED display > > this works. > > You have a big advantage -- a working system to compare against. > Monitor all the lines and compare what the Basic program is sending and > what your other application is sending. Try to mimic the working > signals in your second program. > > -- > Thad
I have a serial port sniffer programme which moniters my com port , the exact same out put is sent to the serial port by both programmes , but the c programme doesnt work! I have also used a scope to monitor activity on the tx line and there is always some data sent ( although I have not decoded the bit pattern yet) . As I mentioned before the C programme transmits correctly to my palm top directly (DCE)and to another PC with null modem. And the data sent is always correct. Can the issue be to do with timing i.e. the basic programme is interpreted and is a lot simple? where as I use read and write library function (overhead etc.) and the LED driver is not tolerant of such delays? Thanks Rate

Memfault Beyond the Launch