serout / serin format

russbow

Senior Member
This is a very silly question I don't doubt, and I suspect the answer is " Because it is! "

Why, when transmitting data, do we put the qualifier AND variables within the brackets thus

Code:
serout c.2,T600_4,($AA, $BB, $CC,b0,b1,b2,b3,b4,b5,b6) 'Output data
and on receive we only put the qualifier in the brackets.

Code:
 serin ANT,T600_4,( $AA, $BB, $CC ),b0,b1,b2,b3,b4,b5,b6
Also Syntax is passed if the brackets in the serin line are put before $AA and after b6
 

hippy

Technical Support
Staff member
Why, when transmitting data, do we put the qualifier AND variables within the brackets ... and on receive we only put the qualifier in the brackets.
You guessed it; because that's the way it is!

There's not really any notion of qualifiers when sending, only data to be sent.

Also Syntax is passed if the brackets in the serin line are put before $AA and after b6
That's correct; but one command will be doing one thing while the other will be doing somnething else ...

SerIn ANT, T600_4, ( $AA, $BB, $CC ), b0, b1

Will wait until the $AA,$BB,$CC sequence is received then put two bytes into b0 and b1

SerIn ANT, T600_4, ( $AA, $BB, $CC, b0 ), b1

Will wait until the $AA, $BB, $CC plus byte value that is currently held in b0 is received then put the next byte into b1.

SerIn ANT, T600_4, ( $AA, $BB, $CC, b0 , b1 )

Will wait for the five byte sequence that matches $AA, $BB, $CC plus whatever values are held in b0 and b1 then continue.
 

russbow

Senior Member
Thanks Hippy. clear explanation for "because it is". Actually clarified reason for qualifiers.

Are you saying here

Will wait for the five byte sequence that matches $AA, $BB, $CC plus whatever values are held in b0 and b1 then continue.
that the incoming string must match the values held in b0 and b1 in the receiving chip? Say b0 =7 and b1 = 8 so nothing is executed until
$AA,$BB,$CC,7,8 is received?
 

westaust55

Moderator
That is correct.

Re the brackets - another way to say it:
SERIN needs some way to identify what part, if any, is the qualifier.
 

hippy

Technical Support
Staff member
Yep. And that's a trap I've occasionally fallen into ...

SerIn ANT, T600_4, ( b0 )
SerTxd( b0 )

Waits for a character that matches b0 rather than reads a byte into b0. b0 is usually zero because it's never been initialised to anything else, so the program just hangs forever if receiving printable characters.

Thinking the command is right, the first suspicion is that it's not receiving any data, the hardware is connected to the wrong pin, the sender isn't sending.
 

russbow

Senior Member
Thinking the command is right, the first suspicion is that it's not receiving any data, the hardware is connected to the wrong pin, the sender isn't sending.
Strangely, that is exactly what prompted the question in the first place!

@Westy
SERIN needs some way to identify what part, if any, is the qualifier.
Thanks, sums it up nicely

Now to have an eyeball to eyeball confrontation with the project and find out why it isn't working.

R.
 

Technical

Technical Support
Staff member
This is a very silly question I don't doubt, and I suspect the answer is " Because it is! "

Why, when transmitting data, do we put the qualifier AND variables within the brackets thus
Technically the reason is valid, although we agree it doesn't at first appear so.

Within 'serin' the brackets are required to tell the compiler when qualifiers stop and receiving variables start. Without having brackets the compiler would be unable to distinguish between the two different types - and this is very important as within the PICAXE firmware they are processed completely differently - two completely different actions for the serin firmware to do.

Within 'serout' processing it is the same action for all - just transmit the byte regardless of what it is.
 

russbow

Senior Member
Why is it common practice to use a qualifier of three character long, and why usually $AA, $BB, $CC ?

I recall some time ago that this was recommended to me as I was dropping the first data byte on receive. Now as a matter of course I use

SerOut c.2,T600_4, ("UUUUUUUUUUUUU") 'wake up Rx
serout c.2,T600_4,($AA, $BB, $CC,b0) 'Output data
What would be the effect of dropping the $CC, or adding $DD? I have noticed that the "wake up" needs at least 5 U's.
 

russbow

Senior Member
EC. Really good link. Thank you. And a further link from that one was equally educational.
Noting that the original is three years old, you must have incredible memory or ( and ) highly honed search abilities.
Thanks,
R.

BTW, where in "Middle England" are you? Bit wet today ??
 
Top