Getting a string from a serial line
bazi
Posts: 29
I'm trying to modify propcmd to receive a file from my computer and write it to sd-card.
Serial communication works, but i can't figure out how to get a string usable with str-function from FullDuplexSerial and fsrw.popen()
I've tried this, but it does not work:
I hope you can help me [noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
some say the devil is dead... ...tish army!
Serial communication works, but i can't figure out how to get a string usable with str-function from FullDuplexSerial and fsrw.popen()
I've tried this, but it does not work:
VAR filename[noparse][[/noparse]9] ext [noparse][[/noparse] 4] ... PUB .... ... count := 0 ' get 8 bytes filename from host repeat while count < 8 header_filename[noparse][[/noparse]count] := text.rx text.tx(header_filename[noparse][[/noparse]count]) count++ header_filename[noparse][[/noparse]8] := 0 count := 0 ' get 3 bytes extension from host repeat while count < 3 header_ext[noparse][[/noparse]count] := text.rx text.tx(header_ext[noparse][[/noparse]count]) count++ header_ext := 0 text.str(string("filename: ")) text.str(filename) text.tx(".") text.str(ext)
I hope you can help me [noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
some say the devil is dead... ...tish army!
Comments
Or even better yet use text.str(@header_filename), because that is where you collect the string!?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pullmoll's Propeller Projects
Post Edited (pullmoll) : 6/17/2010 3:02:52 PM GMT
variables in spin can contain a maximum of 4 bytes = 32 bit = 1 long
strings are stored as a bytesequence. Like you do with
How should a 32bit-variable contain 8 characters? Rhetoric question: it's not possible.
So characters are stored as a sequence of bytes and you need to know WHERE this sequence of bytes is located in RAM
That's what the str-method needs. The ADRESS WHERE the bytesequence ist stored.
So you have to code @NameOfVariable like pullmoll sugested.
the @-operator gives back the desired pointer to the RAM-adress of the variable
"MyVariable" evaluates to the value of MyVariable
"@MyVariable" evaluates to the RAM-adress where the value of MyVariable is STORED in RAM
best regards
Stefan
TY
Jeff T.