• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 478
  • Last Modified:

Serial Port Programming

Hi, i have written an app that writes a datastring to the comm port every second. When i used the monitoring ultility provided by the multi port board vendor...it appears..that the port has been successfully opened and data are transmitting. But my device don't seems to be acting upon receiving the data...... Anyway maybe i could have the datastring format screwed up.

Here's the datastring format given

<STX><POL><5 byte Ascii data><Space><PCS><CR><LF>

STX is chr(12),
POL which is either -ve or +ve...which is always chr(43) in my case
5 byte Ascii Data - i hardcoded it to be 55555
Space which is chr(32)
PCS which are 3 bytes chr(80), chr(67) and chr(83)
CR - return carriage chr(13)
LF - LineFeed chr(10)

In my code...i put it as

myValue = 55555
str_tx = chr(12) & chr(43) & myValue & chr(32) & chr(80) & chr(67) & chr(83) & _
            chr(13) & chr(10)

I am not sure if it is the way present my datastring.... By the way....if i were to type to above string using hyperterminal...how do i present it? like? STX+55555 PCS
what about the CR and LF and space character when testing it with hyperterminal?
  • 4
  • 3
1 Solution
I used this program to talk with COM port in binary mode:

This is my question with additional information:

You need to find also some COM port sniffer and to test what data is sent by your program. I don't think that using string variable is right way. Use Byte array instead.
jaxrpcAuthor Commented:
yup actually the data i sent in bytes...btyeArrary() = Encoding.ASCII.GetBytes(str_Tx)  
Test GetBytes return value in debugger. I am not sure that 55555 gives 5 bytes, each one is 5 (BTW, should it be 5 or '5'?). I think that this is better to work directly with Byte array.
Using program mentioned in my first post, get device working. You can set COM port parameters and send bytes giving their values as Hex numbers, and read device reply. Only when you see that device is really working and responds as expected, try to do the same with your program. This is standard to make such programs - in your current state, you don't know whether your program is wrong, or device is not working, or cable is not working, or you are using incorrect port settings.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

jaxrpcAuthor Commented:
I see...the link u gave is not working.... anyway what's the name of the program? maybe it is still available somewhere on the net.
I can post you this program name later, it is kept on one of my CDs, I don't have it here right now.
You can save your time asking this question in Programming and Hardware areas (give also link in the C area). Generally, you need program like Hyper Terminal, which can work with COM port (additional options like sockets are not required), and allows to type and read binary information.
jaxrpcAuthor Commented:
thanks...sorry but if i were to use the hyperterminal to test it......in the textArea how do i present my dataString? Like ...... just simply type STX+12345 PCSCRLF ??
Sorry i am really new to this....and i am also not good with bits and bytes
I have never try to work with Hyper Terminal in binary mode. Usually I am working with COM port with my own program, written in C++. I also successfully worked with another program, but link to it is not working now.
You will not find many programmers who know communications here in VB .NET area. I suggest you to ask questions which are not related to VB, in C and C++ areas. Real time programmers can help you to fix many problems except your code in VB.
I will post program name later.
You can try out those tools
Really useful to me for every serial communication aspect

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now