propeller serial comms problems
realolman
Posts: 65
I have in the propeller an array called "parameters", which I am trying to populate, and communicate with, using a visual basic express program.
It·mostly works, but it often does not... it is unreliable.·
from the VB program I am sending a "#"· just to let the propeller know something is coming, followed by a number and a chr(13) and another number and another chr(13).·
Then the propeller is sending back to the computer what it just received, so I know it got it.· It adds a "P" and an "=" so the VB program can strip it down to the values of interest.· Sometimes the values·are one digit, sometimes two, three, or four
this is the code in the propeller:
··
Is there a way I can make this more reliable?
thanks
It·mostly works, but it often does not... it is unreliable.·
from the VB program I am sending a "#"· just to let the propeller know something is coming, followed by a number and a chr(13) and another number and another chr(13).·
Then the propeller is sending back to the computer what it just received, so I know it got it.· It adds a "P" and an "=" so the VB program can strip it down to the values of interest.· Sometimes the values·are one digit, sometimes two, three, or four
this is the code in the propeller:
··
If ser.rxcheck <> -1 'checks to see if serial input. 'if nothing there, returns -1 send any character 'to make true WhichVariable := ser.rxDec 'receive a number and a carriage return chr(13) ( which element of the array "Parameter") InputVariable := ser.rxDec 'receive a number and a carriage return chr(13) (what to put in the element of the "Parameter" array) 'Tx parameter back to computer to ensure 'it has been received by propeller ser.str(string("P" )) ' distinguishing character ser.dec(WhichVariable) ser.str(string("=")) ' shows where value begins ser.dec(InputVariable) 'value of parameter ser.tx(13) ser.tx(10) Parameter[noparse][[/noparse]WhichVariable]:=InputVariable 'load the array element with the value received
Is there a way I can make this more reliable?
thanks
Comments
[noparse][[/noparse]PUB CommandLoop| i ' start command receive&process cycle
'Now, start command receive&process cycle
repeat
'wait for command code prefix
repeat
i:=GetB
until i==CommandPrefix 'wait for the command code prefix, $C5
'get command group code
case GetB
"G": 'General commands group
ProcessGeneralCommand
"T": 'Text commands group
ProcessTextCommand]
This works well for me. I don't have sufficient insight to describe properly whether there is an effective difference between Rayman's method compared to yours; but I think that this 'wait for command code' is more deterministic.
T o n y
'Now, start command receive&process cycle
repeat
'wait for command code prefix
repeat
i:=GetB
until i==CommandPrefix 'wait for the command code prefix, $C5
'get command group code
case GetB
"G": 'General commands group
ProcessGeneralCommand
"T": 'Text commands group
ProcessTextCommand]
Re-posted the snip from Rayman's code in an effort to show its indentation properly.
T o n y
Jeff T.
·
Unfortunately I am not understanding what you want me to do.· Do you want me to abandon what I have and·start over with·something else?.
I appreciate everyone's help, but I think that even though you have found code that works for you, I don't think I am willing to abandon mine and try to figure out what is going on with yours, and make the necessary changes to both my VB code and my spin code.·· I think I would become·completely lost If I tried to start over with something else.
I was hoping perhaps you would help me figure out why what I have doesn't seem to work reliably.
When the··
· line encounters a received transmission it executes the code below it.· ( The indentations seem to suffer in cutting and pasting )
How can I make sure that the transmission I sent to the propeller is completely received by the propeller, before it assigns what it received to a variable in the propeller?· How can I know it's not assigning an unfinished transmission to the variable?
The numbers I will send to the propeller in this application could be any integer between 0 to 1200.
Thank you in advance
Post Edited (realolman) : 1/2/2010 9:05:20 PM GMT