Results 1 to 14 of 14

Thread: [RESOLVED] Question about serialport component.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    739

    Resolved [RESOLVED] Question about serialport component.

    In the windows Com API there is a flow control settings such as

    NONE
    XonXoff
    RTS/CTS
    Xon/Xoff/RTS/CTS

    That last one makes the port react to both xon/xoff software handshaking as well as RTS/CTS hardware handshaking.

    But, using the .Net serialport component I don't want that option. I just want XonXoff and I want it to ignore CTS. But I'm finding that if I set the serialport control to XonXoff that it actually uses RTS/CTS as well.

    I'm going to keep testing this for a work-around but, in the meantime, if anyone has any ideas please let me know.

    Thanks
    Ian

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Question about serialport component.

    I'm afraid that I don't know the solution to your problem but I just had to post and say OH MY GOD, finally someone who calls a component a component instead of just calling everything in the Toolbox a control. Kudos for that.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    739

    Re: Question about serialport component.

    Thank you. Telling me that you don't know really does help. It tells me that I'm not going to find the solution as a property of the control or in the control toolbox - where all the other controls are.

  4. #4
    Addicted Member
    Join Date
    Oct 2008
    Location
    USA
    Posts
    150

    Re: Question about serialport component.

    I am no expert, but have you read this. ( I am sure you have)

    http://msdn.microsoft.com/en-us/libr...handshake.aspx

    and this bit about handshaking.

    http://msdn.microsoft.com/en-us/libr...handshake.aspx

    I hope I am not trying to "teach my granny to suck eggs". ( quick translation. telling you something you already know)
    Think.... Question.....

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    739

    Re: Question about serialport component.

    Quote Originally Posted by 2ndmessiah View Post

    I hope I am not trying to "teach my granny to suck eggs"
    Yes, here in the UK we talk about Egg sucking grannies too. I'm not offended. We don't know each other so there's no way you can know what I do or don't know so please assume I know nothing - I won't be offended.

    Having said that - I do like to think I know my way round a serial port and I've poked this one till it's black and blue all over.

    I could have described my question clearer.

    I'm setting handshaking to XOnXOff but it's working as if it was set to RequestToSendXOnXOff

    I'm kind of thinking it's a bug in my cheap USB/RS232 device (driver)

  6. #6
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: Question about serialport component.

    Quote Originally Posted by IanS View Post
    Yes, here in the UK we talk about Egg sucking grannies too. I'm not offended. We don't know each other so there's no way you can know what I do or don't know so please assume I know nothing - I won't be offended.

    Having said that - I do like to think I know my way round a serial port and I've poked this one till it's black and blue all over.

    I could have described my question clearer.

    I'm setting handshaking to XOnXOff but it's working as if it was set to RequestToSendXOnXOff

    I'm kind of thinking it's a bug in my cheap USB/RS232 device (driver)
    Could you give us the 10,000 foot view of your program? Is your program sending or receiving(or both) the xon/xoff? I wouldn't be surprised if you are correct about the usb driver.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    739

    Re: Question about serialport component.

    Don't need 10000 foot of the program.

    pseudo code

    Handshaking = xonxoff
    open port
    send data
    '// Data does not flow.
    '// Use a bent paper clip to short RTS/CTS and data flows.


    When handshaking is set to RequestToSendXOnXOff then that is what I would expect. I would not expect it when handshaking is set to just XonXoff.

    Actually poking about in the API and DCB I can see that the DCB is dirty. When setting XonXoff the RTS/CTS bits are left in an uninitialized and therefore unknown state. I thought the only way to clear this would be to set handshaking = NONE to make sure all the handshaking bits in the DCB are cleared before setting XonXoff. When doing that via the API it appears to work - doing it via the serialport component it doesn't.

  8. #8
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: Question about serialport component.

    If you set handshake to none does it work? I was asking about the 10,000 foot view to see why you were using handshaking.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    739

    Re: Question about serialport component.

    I write an application that is used to program/configure machinery, robotics etc. It allows the user to select whatever flow control his specific devices require. He can select NONE or RTS/CTS or XonXoff. So, ' I' don't use anything. My users do. And if they select XonXoff they want XonXoff. They do not want RequestToSendXOnXOff.

    Yes, if set to NONE then there is no problem. CTS is ignored if flow control is none. basically I'm getting this:-

    If I set None
    I get None

    If I set RTS/CTS
    I get RTS/CTS

    If I set xOnxOff
    I get RequestToSendXOnXOff

  10. #10
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: Question about serialport component.

    So don't set handshake to xon/xoff if that is what they select in your program. Instead mimic the behavior by watching for those bytes. I think xon is DC1(17), and xoff is DC3(19) if memory serves me.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  11. #11
    Addicted Member
    Join Date
    Oct 2008
    Location
    USA
    Posts
    150

    Re: Question about serialport component.

    One thought comes to mind. If your Hand shaking is set to XOn/Xoff. Does it matter if the RTS pin is raised if the pin isnt actually connected to anything. As long as the appropriate flow control bytes are sent.
    By the way your initial question was very clear. Its my understanding that is lacking.
    Last edited by 2ndmessiah; Oct 11th, 2012 at 12:20 PM.
    Think.... Question.....

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    739

    Re: Question about serialport component.

    Quote Originally Posted by dbasnett View Post
    So don't set handshake to xon/xoff if that is what they select in your program. Instead mimic the behavior by watching for those bytes. I think xon is DC1(17), and xoff is DC3(19) if memory serves me.
    USB has very big transmit buffers and once data is loaded in to the transmit buffer then I can't stop it being sent.

    If I see an incoming DC3 then I can stop loading data into the transmit buffer but whatever was already in the buffer will still be sent. That amount of data is often too much for the remote device and it throws a receive buffer overflow alarm.

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    739

    Re: Question about serialport component.

    Just wanted to add that the problem doesn't happen if the com port is a proper com port. It only happens on my cheapo USB/RS232 adapter.

  14. #14
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: Question about serialport component.

    Quote Originally Posted by IanS View Post
    USB has very big transmit buffers and once data is loaded in to the transmit buffer then I can't stop it being sent.

    If I see an incoming DC3 then I can stop loading data into the transmit buffer but whatever was already in the buffer will still be sent. That amount of data is often too much for the remote device and it throws a receive buffer overflow alarm.
    I wrote this little test for my USB adapter:

    Code:
        Dim sp As New IO.Ports.SerialPort
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            If Not sp.IsOpen Then
                Dim foo() As String = IO.Ports.SerialPort.GetPortNames
                sp.Handshake = IO.Ports.Handshake.XOnXOff
                sp.DtrEnable = True
                sp.PortName = foo(0)
                sp.Open()
            Else
                sp.Close()
            End If
        End Sub
    RTS/CTS did not come on.

    Have you changed the WriteBufferSize property?

    What speed are the devices you are communicating with?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width