Page 1 of 1

Can I use newlisp's read to read serial data for sure?

Posted: Sun Dec 22, 2013 11:10 am
by dexter
I use stty to config serial port,this part is ok as far as we know

Then I use newlisp's read function (read) to read the data from serial port

most of the time,it's ok ,the data was ok and right

just a few chance, it'll get the wrong,short data, seems lost or mixed parts of

so wired

after a long time until now,I have a question, Can I really use newlisp's read to read serial port??

I doubt it myself now, I dont think linux can not handle a serial communication.

Re: Can I use newlisp's read to read serial data for sure?

Posted: Sun Dec 22, 2013 8:13 pm
by TedWalther
It should work; are the read's timing out?

Re: Can I use newlisp's read to read serial data for sure?

Posted: Mon Dec 23, 2013 5:04 am
by dexter
No timeout ,i just set it to wait the data forever to read

Re: Can I use newlisp's read to read serial data for sure?

Posted: Mon Dec 23, 2013 7:18 am
by TedWalther
Are you reading a byte at a time? And what settings are you using on the tty? What happens if you "tail -f" the tty device?

Re: Can I use newlisp's read to read serial data for sure?

Posted: Mon Dec 23, 2013 12:46 pm
by dexter

Code: Select all

root@OpenWrt:~# stty -F /dev/ttyUSB0 
speed 38400 baud; line = 0;
min = 150; time = 1;
ignbrk -brkint -icrnl -imaxbel
-opost -onlcr
-isig -icanon -iexten -echo -echoe -echok noflsh -echoctl -echoke
Not reading a byte from serial, I read a lot of data from serial port
for example

I read

Code: Select all

a0 ec fc 00 00 e5 c8 a0 b0 19 00 00 e5 c8 a0 fc 7f 00 00 e5 c8 
the data above is ok
now this below

Code: Select all

a8 ec fc 00 a8 b0 19 a8 fc 7f 
Now the right data will be

Code: Select all

a8 ec fc 00 a8 b0 19 00 a8 fc 7f 00
two "00" lost ,I dont know why, the data is shortter than "0xa0" data, right?

and I use the same way to send data from my chip 8051 to openwrt
some times , it will be a8 ec fc 00 a8 b0 19 00 a8 fc 7f, only one "00" lost

I am so confused , because of 0xa8 is different to 0xa0? I use 0xa0,0xa8 to be the head flag of my data.

Re: Can I use newlisp's read to read serial data for sure?

Posted: Mon Dec 23, 2013 4:02 pm
by dexter
I finally got this issue

if my device send 0x11 to openwrt , newlisp can not read it; 0x12 is ok ,0x01 is ok ,so else ,I could not test them all

That's why it lost data ,because the lost data is 0x11....


So wired problem...

Re: Can I use newlisp's read to read serial data for sure?

Posted: Mon Dec 23, 2013 6:16 pm
by TedWalther
dexter wrote:So wired problem...
Sorry, did you mean "wierd" problem, or rather, problem with the wiring of your device? And does the data correctly show up when you run "tail -f /dev/ttyS0" ?

Re: Can I use newlisp's read to read serial data for sure?

Posted: Tue Dec 24, 2013 6:14 pm
by fred
0x11 is the code for XON Resume transmission, could it be "eaten" as a flow control character?
I do not know stty but perhaps something like -ixon -ixoff or raw mode?

Re: Can I use newlisp's read to read serial data for sure?

Posted: Thu Dec 26, 2013 7:13 am
by dexter
yeah
After I send my last reply
I know 0x11 0x13 0x0d is some CODE

now it seems working now,thanks all :)