Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Serial Port Buffering and non canonical mode

Need help with peripherals or devices?
Post Reply
Message
Author
fsonnichsen
Posts: 11
Joined: 2015-11-30 18:44

Serial Port Buffering and non canonical mode

#1 Post by fsonnichsen »

I have been struggling with this for a few days and would appreciate some advice. I am running a PERL serial program on a Debian system. Connected to an USB emulated serial port is a steaming hardware device that sends a ~50 byte record ever few seconds. An stty shows -icanon so I am assuming non blocking mode here.

I read this port/device periodically, about every 30 seconds.My read is done in PERL with a byte by byte loop. It "spins" until the accumulated number of bytes is retreived. When i read, I need the MOST RECENT record. However I keep getting "stale" data, that is, an earlier record. I think my understanding of the serial port is the issue here so I have some questions:
1) Where would the serial port buffer be maintained--in Debian or in the PERL control sections
2) How does the read of the port work. I already assume based upon what I am seeing is that it if FIFO, e.g. the oldest record is returned first. I am guessing some type of ring buffer is established either in Debian or PERL.

Is there some way to insure that I get the most recent bytes transmitted. I was thinking of setting the buffer size to some low value to insure that is is flushed when I do the read but I cannot see an stty or ioctl mandate to do this.

Thanks
Fritz

peter_irich
Posts: 1405
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: Serial Port Buffering and non canonical mode

#2 Post by peter_irich »

The earliest data transmitted to serial port will be read the first and the last data will be read last.
In one ed of the pipe data are arrives and from other its gets out.
Read in while() by portion what you needed until the date will be finished and leave the last.

Peter.

Post Reply