none
.Net SerialPort class Write buffer information. RRS feed

  • Question

  • When writing to an open SerialPort, how can I determine if there is enough room in the write buffer, considering that it may already have contents waiting to send (i.e. writeBufferSize - #bytesQueuedToSend )

    I seen there is timeout event if I overwrite, but can I prevent this?


    Code to Joy - aka Ludwig

    Monday, October 3, 2016 5:52 PM

Answers

  • Hi NK3,

    >>When writing to an open SerialPort, how can I determine if there is enough room in the write buffer, considering that it may already have contents waiting to send

    As far as I know, it seems that we could set the size of the serial port output buffer via WriteBufferSize , and we could use BytesToWrite Property to get the number of bytes of data in the send buffer.

    >>I seen there is timeout event if I overwrite, but can I prevent this?

    We could increase WriteTimeout (Gets or sets the number of milliseconds before a time-out occurs when a write operation does not finish.) value to avoid it.

    Best regards,

    Cole Wu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by NK3 Tuesday, October 4, 2016 6:39 PM
    Tuesday, October 4, 2016 2:28 AM
    Moderator

All replies

  • Hi NK3,

    >>When writing to an open SerialPort, how can I determine if there is enough room in the write buffer, considering that it may already have contents waiting to send

    As far as I know, it seems that we could set the size of the serial port output buffer via WriteBufferSize , and we could use BytesToWrite Property to get the number of bytes of data in the send buffer.

    >>I seen there is timeout event if I overwrite, but can I prevent this?

    We could increase WriteTimeout (Gets or sets the number of milliseconds before a time-out occurs when a write operation does not finish.) value to avoid it.

    Best regards,

    Cole Wu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by NK3 Tuesday, October 4, 2016 6:39 PM
    Tuesday, October 4, 2016 2:28 AM
    Moderator
  • I missed that property and it appears to be exactly what I needed. Thank you. 


    Code to Joy - aka Ludwig

    Tuesday, October 4, 2016 6:40 PM