Send string through serial port
mytrax
Posts: 2
Hi,
I burned my brain since two days looking for a solution !
I got some trouble with RS232 communication. I wrote a VB.net program in order to send to the propeller the coordinates of a joystick connected to my PC . I can receive those data but I can't differentiate them. Take a look :
Part of my VB.net Prog :
I send those informations to my propeller :
RS232.WriteLine(state.Y)
RS232.WriteLine(state.X)
RS232.WriteLine(state.GetPointOfView(0))
RS232.WriteLine(state.GetSlider(0))
RS232.WriteLine(state.Rz)
And I receive them with the "Full-Duplex_COMEngine" object like that :
serial.readString(@data, 512)
The problem is that I can't differentiate all the incoming datas. I would like to put state.Y , state.X ... in differents VAR. Or maybe in an array.
I tried that :
repeat until index == 4
char := serial.readString(@data, 512)
str[index] := char
index++
but it doen't works
Could you help me please ? Sorry but I'am a newbie :-D
I burned my brain since two days looking for a solution !
I got some trouble with RS232 communication. I wrote a VB.net program in order to send to the propeller the coordinates of a joystick connected to my PC . I can receive those data but I can't differentiate them. Take a look :
Part of my VB.net Prog :
I send those informations to my propeller :
RS232.WriteLine(state.Y)
RS232.WriteLine(state.X)
RS232.WriteLine(state.GetPointOfView(0))
RS232.WriteLine(state.GetSlider(0))
RS232.WriteLine(state.Rz)
And I receive them with the "Full-Duplex_COMEngine" object like that :
serial.readString(@data, 512)
The problem is that I can't differentiate all the incoming datas. I would like to put state.Y , state.X ... in differents VAR. Or maybe in an array.
I tried that :
repeat until index == 4
char := serial.readString(@data, 512)
str[index] := char
index++
but it doen't works
Could you help me please ? Sorry but I'am a newbie :-D
Comments
It helps if you use code tags when posting code. Here's a link to learn how.
I do this with code like this, if you need more specific help, we'll need more specifics and specific code
Thanks for your answer, but I'a code, I'am a real newbie !
For more informations ; in fact I would send that through my pc : "122|999|647|455" and catch all numbers between "|" and put them in differents variables.
I tried to wrote my code ; take a look :
But it doen't worl , I think I'am near the solution ! Help me please ^^ !
I just saw your reply. Try the example I've attached and see if you can adapt it to what you'd like to do.
If you type "bob=100" you'll see it parse through the data and give the values before the equals sign and after the equals sign.
Let me know how this works for you.
It would help if you took another look at the code tags link I posted earlier. Using a quote block doesn't keep the indentation that is so important in Spin.
I see you want to use "|" as a delimiter but you're sending values that you want stored in certain variables right? What indicator is there to indicate a new message? What are the end of messae charaters?
It's common to use a carriage return to indicate an end of message. It would also help if you had some sort of beginning of message indicator.
Is the data "122|999 etc" sent as ASCII characters? Where "122" is three bytes?
You mentioned you want the data assigned to various variables. In your example where you're sending four numbers, do you want to keep reusing the same four variables (such as (I'm just making these up) "xAxis", "yAxis", "zAxis" and "buttonValue")?