-
Oct 11th, 2012, 06:48 AM
#1
Thread Starter
Fanatic Member
[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
-
Oct 11th, 2012, 07:44 AM
#2
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.
-
Oct 11th, 2012, 08:05 AM
#3
Thread Starter
Fanatic Member
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.
-
Oct 11th, 2012, 08:25 AM
#4
Addicted Member
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)
-
Oct 11th, 2012, 08:56 AM
#5
Thread Starter
Fanatic Member
Re: Question about serialport component.
Originally Posted by 2ndmessiah
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)
-
Oct 11th, 2012, 10:11 AM
#6
Re: Question about serialport component.
Originally Posted by IanS
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.
-
Oct 11th, 2012, 10:31 AM
#7
Thread Starter
Fanatic Member
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.
-
Oct 11th, 2012, 10:45 AM
#8
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.
-
Oct 11th, 2012, 10:56 AM
#9
Thread Starter
Fanatic Member
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
-
Oct 11th, 2012, 11:59 AM
#10
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.
-
Oct 11th, 2012, 12:09 PM
#11
Addicted Member
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.....
-
Oct 11th, 2012, 12:26 PM
#12
Thread Starter
Fanatic Member
Re: Question about serialport component.
Originally Posted by dbasnett
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.
-
Oct 11th, 2012, 12:50 PM
#13
Thread Starter
Fanatic Member
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.
-
Oct 11th, 2012, 02:19 PM
#14
Re: Question about serialport component.
Originally Posted by IanS
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|