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

Q&A's, tips, howto's
Locked
dexter
Posts: 74
Joined: Fri Nov 11, 2011 12:55 am

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

Post 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.

TedWalther
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

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

Post by TedWalther »

It should work; are the read's timing out?
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence. Nine months later, they left with a baby named newLISP. The women of the ivory towers wept and wailed. "Abomination!" they cried.

dexter
Posts: 74
Joined: Fri Nov 11, 2011 12:55 am

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

Post by dexter »

No timeout ,i just set it to wait the data forever to read

TedWalther
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

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

Post 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?
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence. Nine months later, they left with a baby named newLISP. The women of the ivory towers wept and wailed. "Abomination!" they cried.

dexter
Posts: 74
Joined: Fri Nov 11, 2011 12:55 am

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

Post 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.

dexter
Posts: 74
Joined: Fri Nov 11, 2011 12:55 am

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

Post 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...

TedWalther
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

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

Post 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" ?
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence. Nine months later, they left with a baby named newLISP. The women of the ivory towers wept and wailed. "Abomination!" they cried.

fred
Posts: 8
Joined: Wed Oct 15, 2008 2:24 pm

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

Post 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?

dexter
Posts: 74
Joined: Fri Nov 11, 2011 12:55 am

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

Post by dexter »

yeah
After I send my last reply
I know 0x11 0x13 0x0d is some CODE

now it seems working now,thanks all :)

Locked