Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full duplex on Windows #150

Open
zeeMonkeez opened this issue Feb 27, 2017 · 1 comment
Open

Full duplex on Windows #150

zeeMonkeez opened this issue Feb 27, 2017 · 1 comment

Comments

@zeeMonkeez
Copy link

In testing a project on a Windows machine I noticed that apparently concurrent read/write operations are not supported on Windows: while reading data, the writing thread seems to block.
I did come across this article describing the FILE_FLAG_OVERLAPPED flag to initiate overlapped operations. Not knowing much about the Windows Serial API I don't know whether this is still relevant.
I do use .setTimeout (0, 1, 0, 0, 0); to reduce the time outs, however I also then start to lose data...

@brooksbp
Copy link

brooksbp commented Jan 1, 2019

I ran across the same situation, but was surprised when I measured it. This was with my own code which is similar to the code in this project but does not use a lock (it's single-threaded).

Numbers for a UART device in hardware loopback (assign TXD = RXD):

  // Note that even though the software appears to be half-duplex, e.g.                                                                 
  //                                                                                                                                    
  //   for (;;) {                                                                                                                       
  //     tty.Write(..);                                                                                                                 
  //     tty.Read(..);                                                                                                                  
  //   }                                                                                                                                
  //                                                                                                                                    
  // the measured data rate is closer to full-duplex (for larger buffers):                                                              
  //                                                                                                                                    
  //   9600 baud:                                                                                                                       
  //                                                                                                                                    
  //   buffer_size=1B duration=799819us  TX bps=500.113 RX bps=500.113                                                                  
  //   buffer_size=4B duration=799951us  TX bps=2000.12 RX bps=2000.12                                                                  
  //   buffer_size=16B duration=1599840us  TX bps=4000.4 RX bps=4000.4                                                                  
  //   buffer_size=64B duration=3999859us  TX bps=6400.23 RX bps=6400.23                                                                
  //   buffer_size=256B duration=13599317us  TX bps=7529.79 RX bps=7529.79                                                              
  //   buffer_size=1024B duration=53597703us  TX bps=7642.12 RX bps=7642.12                                                             
  //                                                                                                                                    
  //   112500 baud:                                                                                                                     
  //                                                                                                                                    
  //   buffer_size=1B duration=799891us  TX bps=500.068 RX bps=500.068                                                                  
  //   buffer_size=4B duration=799956us  TX bps=2000.11 RX bps=2000.11                                                                  
  //   buffer_size=16B duration=799953us  TX bps=8000.47 RX bps=8000.47                                                                 
  //   buffer_size=64B duration=799911us  TX bps=32003.6 RX bps=32003.6                                                                 
  //   buffer_size=256B duration=1599892us  TX bps=64004.3 RX bps=64004.3                                                               
  //   buffer_size=1024B duration=4799703us  TX bps=85338.6 RX bps=85338.6                                                              

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants