Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- octave:38> sif0 = "/dev/pts/2";
- octave:39> sif1 = "/dev/pts/3";
- octave:40> s0 = serial(sif0, 115200);
- octave:41> s1 = serial(sif1, 115200);
- octave:42>
- octave:42> # Example 1: blocking read, returns exactly 6 bytes (old behavior)
- octave:42> srl_flush(s0); srl_flush(s1); srl_write(s0, "Hello1!"); [data, count] = srl_read(s1, 7); char(data), count
- ans = Hello1!
- count = 7
- octave:43>
- octave:43> # Example 2: non-blocking read, returns 6 bytes from buffer immediately (n.b. tried to read up to 10, only 6 written to the buffer)
- octave:43> srl_timeout(s1, 0); srl_flush(s0); srl_flush(s1); srl_write(s0, "Hello2!"); sleep(1); tic(); [data, count] = srl_read(s1, 10); toc(); char(data), count
- Elapsed time is 0.00022 seconds.
- ans = Hello2!
- count = 7
- octave:44>
- octave:44> # Example 3: non-blocking read, returns 6 bytes after a timeout of 3.0 seconds (n.b. tried to read up to 10)
- octave:44> srl_timeout(s1, 30); srl_flush(s0); srl_flush(s1); srl_write(s0, "Hello3!"); sleep(1); tic(); [data, count] = srl_read(s1, 10); toc(); char(data), count
- Elapsed time is 3 seconds.
- ans = Hello3!
- count = 7
- octave:45>
- octave:45> # Example 4: non-blocking read, returns no data after timeout of 3.0 seconds (n.b. there was no data available to the interface before reading)
- octave:45> srl_flush(s0); srl_flush(s1); sleep (1); tic(); [data, count] = srl_read(s1, 10); toc(); char(data), count, srl_close(s0); srl_close(s1);
- Elapsed time is 3 seconds.
- ans =
- count = 0
- octave:46>
Advertisement
Add Comment
Please, Sign In to add comment