PDA

View Full Version : Serin2/Serout2 Question



scottl
- 10th November 2007, 06:21
I cannot seem to get the following code to work properly!

serin2 GPIO.5,Baud,2000,mainloop,[str command\20\13]
SEROUT2 GPIO.0,Baud,[str command\20,13]

The data coming in on GPIO.5 is in this format: "A-0000.023 -0000.044 -0000.124 <cr>" all I want to do is just receive the data and forward the data out GPIO.0! Should I be using STR or DEC?

Can anyone point me in the right direction?

Thanks,

Scott

Samoele
- 18th November 2007, 07:55
Hello Scott,

I hope that this help you,

1) A string constant is output as a literal string of characters.
2) A numeric value (either a variable or a constant) will send the corresponding ASCII character. Most notably, 13 is carriage return and 10 is line feed.
3) A numeric value preceded by BIN will send the ASCII representation of its binary value. For example, if B0 = 8, then BIN B0 (or BIN 8) will send "1000".
4) A numeric value preceded by DEC will send the ASCII representation of its decimal value. For example, if B0 = 123, then DEC B0 (or DEC 123) will send "123".
5) A numeric value preceded by HEX will send the ASCII representation of its hexadecimal value. For example, if B0 = 254, then HEX B0 (or HEX 254) will send "FE".
6) REP followed by a character and count will repeat the character, count time. For example, REP A0"\4 will send "0000".
7) STR followed by a byte array variable and optional count will send a string of characters. The string length is determined by the count or when a 0 character is encountered in the string.

BIN, DEC and HEX may be preceded or followed by several optional parameters. If any of them are preceded by an I (for indicated), the output will be preceded by either a A%@, A#@ or A$@ to indicate the following value is binary, decimal or hexadecimal.

If any are preceded by an S (for signed), the output will be sent preceded by a A-A if the high order bit of the data is set. This allows the transmission of negative numbers. Keep in mind that all of the math and comparisons in PBP are unsigned. However, unsigned math can yield signed results. For example, take the case of B0 = 9 - 10. The result of DEC B0 would be A255". Sending SDEC B0 would give A-1" since the high order bit is sent. So with a little trickery, the unsigned math of PBP can yield signed results.

BIN, DEC and HEX may also be followed by a number. Normally, these modifiers display exactly as many digits as are necessary, zero blanked (leading zeros are not sent). However, if a number follows the modifier, SEROUT2 will always send that number of digits, adding leading zeros as necessary. It will also trim of any extra high order digits. For example, BIN6 8 would send A001000" and BIN2 8 would send A00".

Any or all of the modifier combinations may be used at once. For example, ISDEC4 B0.


regards,
Samo

mister_e
- 18th November 2007, 09:11
Can anyone point me in the right direction?
you never even dared to answer the last discussion about that.. so i'll redirect you to it as it worked properly here.

http://www.picbasic.co.uk/forum/showthread.php?t=7501

Before starting a new post ALWAYS close/answer to your previous one(s).