Question Serial port communication problems.

schonertod

Member
Joined
Nov 5, 2010
Messages
9
Programming Experience
1-3
Hey guys new to the forum. I have been playing with visual basic for a few years. I am writing an automation program for an associated research HYPOT tester and one of my current problems is trying to split the data i recieve back from the box.

Currently i have two commands i use
TD? and SALL? both do the same thing but return different data. TD? when sent to the box will return the test results and of course there is no auto return when test is complete so i have to either set some kinda of timer to get the data after the test is complete or just keep pinging the box tell the test returns with either a pass or fail. If any one knows a better way to do that then that would fix one of my other problems

But right now my problem is when i ping the box with TD? it returns

"M11,ACW,test results{pass|fail},1.50,10.00,10ms"

What I am trying to do is use a split command to split that line into strings based off "," as my dilimeter. Currently i am useing this set up

dim resultstring as string = main.serialport1.readexisting
dimresultarray as string = split(resultstring, ",",6)

txtTestResult.Text = resultarray(2)

for the most part is does return the test results but other times it will either error out saying that resultarray(2) is out side the index or it will display one of the other strings (acw or 1.50). Is there a more accurate way to do this. I am also printing the full string pulled from the buffer into a text doc as a data log.
 
yeah, I remember during developing that there are some oddities in cross-thread calls and stuff like this when you drag the object from the toolbar or if you declare it in code.
And I've ended up using everything by code and it's working...

well... good luck!
 
Back
Top