|
-
May 13th, 2022, 08:46 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Serial Port communication Rx/Tx Indicator?
Hello. Using SP control in a 'conventional' way is handy but in some cases it is a total nightmare. I'm not going to expand the conversation therefore, let's jump into the point. It is very user-friendly when the operator can see either serial communication is online or it's down (because your try/catch may show or not show the ex.message if you consider this and also it occurs once. How about someone pressed OK button but failure condition is still going on) via two bullets:
○ ●
Representing Rx/Tx sending/receiving bytes for both of them. You may already seen a bunch of better ones in another applications or maybe phones, PLCs, HMIs and etc. How can we do such thing for example in bulleting a RadioButton control (Due to being checked once at a time only between two of them) the moment a packet sent/received?
Last edited by pourkascheff; May 14th, 2022 at 06:41 AM.
-
May 23rd, 2022, 09:04 AM
#2
Re: Serial Port communication Rx/Tx Indicator?
change the radiobutton status in the proper event :
when it is received, in the event "SerialPort_DataReceived" (as the serialport use a special thread, you need to use BeginInvoke)
Code:
Me.BeginInvoke(Sub()
'radiobutton switch to 1 to said it is receiving
End Sub)
when it is send, in the event where you use SerialPort.Write(message), 'same radiobutton or an other switch to 0 to say it is sending
both combined with a try/catch
you may also use at some point the command SerialPort.IsOpen in the same events to check if the port is open
The best friend of any programmer is a search engine 
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
Tags for this Thread
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
|