Char to Str conversion?
Is there a way to conver character data into string data?
We're working on uploading data to a website using the spinneret, but the issue is that the propeller is receiving the data is char form and then sending it to the website in str form. Is there a way to create a subroutine to convert the char to str?
We're working on uploading data to a website using the spinneret, but the issue is that the propeller is receiving the data is char form and then sending it to the website in str form. Is there a way to create a subroutine to convert the char to str?
Comments
The propeller receives single bytes (chars) now who is sending it as string to what kind of device?
What is teh code-base of the chars? Are the chars ASCII-coded? or do you receive byte-values where a 1 means a 1 and a 128 means a 128 as a number?
For the case that you receive ASCII-coded chars simply receive them in an array of bytes. If the receiving has finished add a zero at the end of the character-seqeunce and then
use a send-str-method like in FullDuplexSerial to send the whole string at once.
If the case is something else you have to provide more specific information of what is going on.
Please add a verbal description and some examples of what you receive and what should be sended.
keep the questions coming
best regards
Stefan
For example:
tx.ch(char) ' transmits a single character
tx.string(@char) ' transmits a single character
But like Stephan I too wonder if your question is correct.
If your string is null terminated like in C and Spin, you'll have to use a temporary buffer with at least 2 chars per string.
' define a buffer with enough space ' use buffer[index] like in C only with VAR variables ... ' DAT variables need different syntax var byte buffer[10] ' stuff character ch into a null terminated string pub char2str(ch) buffer[0] := ch buffer[1] := 0 return @buffer ' return address of buffer