-5

I am looking for reference and pointers on setting vmin and vtimer for recieving streaming serial application. MEssages of varying length are send to the application in at random timing but at a fixed frequency for each message( some messages could be coming at 1 sec while others can be as fast as 10 ms).

There is no sender protocol (no sync byte pattern for telling that the signal byte i recieved is a message nor telling me the length of the message). Though I have the header byte pattern which will tell me the message type and consequently their length. Thus in my programming, I try to read in a fixed number of bytes to a ringbuffer and then subsequently try to reverse locate and match the header from the buffer rear (let say i read in n bytes, I would start to match my byte pattern at n-1 buffer and then n-2... so on and so forth)

Now I am trying to determine to vtime and vmin settings i should set... now i have set them to vtime =1 and vmin =256. I wonder whether this is a correct settings... but i feel like setting both values to be 0, apart from fear of serial read using polling and increase my cpu usages

Does the setting of values also matter with cycle time... ie meaning each read time... if I have a faster read time than vtime, will this affect perfomance and how could i set lower timing than now (0.1s)

Need some pointers and direction

user4581301
  • 33,082
  • 7
  • 33
  • 54
user1538798
  • 1,075
  • 3
  • 17
  • 42
  • If you can read the header and then count the bytes to the next header everytime, I would not worry about timing at all. I would use poll+non-blocking API with e.g. 64KB buffer, then parse the data in-memory from the buffer. – Quimby Aug 28 '23 at 17:31
  • There is a good question in here, but it's not a good fit for Stack Overflow... yet. – user4581301 Aug 28 '23 at 17:53
  • Messages sent "*at random timing*" and "*fixed frequency*" would not dictate any VMIN or VTIME values. If you're using termios, then you're using a userspace application several layers removed from the hardware; see [Linux serial drivers](https://www.linux.it/~rubini/docs/serial/serial.html). Depending on the hardware (e.g. FIFO, DMA), your code and termios may lose most timing information; see https://stackoverflow.com/questions/27152926/parsing-time-delimited-uart-data and https://stackoverflow.com/questions/58898980/how-to-set-inter-byte-delay-timeout-to-milliseconds – sawdust Aug 28 '23 at 22:08
  • See https://stackoverflow.com/questions/17327162/what-is-the-best-way-to-read-and-write-data-to-a-buffer-for-my-bar-code-reader/17329254#17329254 and https://stackoverflow.com/questions/54392470/how-to-handle-buffering-serial-data/54394770#54394770 – sawdust Aug 28 '23 at 22:09

0 Answers0