Help with my code dealing with a table ? ?
I am basically trying "again" to send data over to my propeller using the Full duplex object. The idea is to send over a string from the PC and once the propeller receives it it can exacute a command accordingly.
here is what i have so far
can some one help me write the code? I wish to look up strings of data in a table then my propeller can do something given the string.
here is what i have so far
{ } CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ LCD : "LCDOBJECT" ser : "256_FullDuplexSerial" VAR Long NAME PUB Start | Index , Temp SER.start(31,30,0,9600) lcd.init repeat LCD.cls repeat Temp := ser.rx While ser.rxcheck > 0 Index := 0 repeat Temp := myString[noparse][[/noparse]index++] lcd.writeOut(Temp) waitcnt (1_000_000 * 50 + cnt ) While Temp > 0 DAT myString byte "hello world",0 myString1 byte "This is a test",0
can some one help me write the code? I wish to look up strings of data in a table then my propeller can do something given the string.
Comments
do you mean you have 3 or maybe 255 strings
and with each string the propeller should do something different ?
a much easyier solution could be to just send ONE byte.
Now you are maybe thinking: oh how should i keep the overview if i have to deal with numbers from 1 to 255 ?
that's no problem you can define constants
etc.
if i look into your sourcecode i do not understand what you want to to
could you please comment EACH line of your code and write what YOU THINK it does
if i try to understand
repeat
Temp := ser.rx
While ser.rxcheck > 0
get bytes out of the receivebuffer and OVERWRITE each last received bytevalue by the next one that is received
Temp can hold only ONE long
if you want to receive more than one byte
you have to define an array of bytes
there is an object with name "serialmirror" in the object exchange
Inside of this object is a method RxStr which receveives a complete string that terminates with a carriage return
it works like this: the bytes of the string are stored into an bytearray
if you have more questions feel free to post CONCRETE questions
regards
Stefan
Not really. Take it a step at a time and try and get one thing understood and working before trying to combine multiple things which aren't understood and don't work.
Let's start with reading a received character - have you read the comments in the Full Duplex Serial object ? For rxcheck ...
'' Check if byte received (never waits)
'' returns -1 if no byte received, $00..$FF if byte
So to read a received byte, assign the returned value for a call to rxcheck, then see if that value was greater or equal to zero, if so something was received, otherwise try again ...
Alternatively, save doing all that yourself and simply call the rx method and that waits until something is received then returns ...
It's either one way or another. No need to call rxcheck after calling rx unless you are trying to do something far more complicated than it appears you are.
I don't know what hardware you have but I recommend connecting up a TV then you have a very easy to use debugging display which can show what's received and what's happening in your program ...