Newzed
01-30-2007, 11:00 PM
I have been playing around with my Stamp-over-Stamp piggyback.· When I send "A" to the Slave,·I wanted it to send back "Communication established".· This·takes 24 bytes.· To declare a variable
serstring· VAR· byte(24)
used up almost all of my variable space.· So I looked for another alternative - the DO/LOOP routine.· Now when I send an "A" to the Slave, it sends back:
---------------------------------------------------------------------
SEROUT so\fc, baud, ["Communication OK", 13, "You are clear to send",13,10]
---------------------------------------------------------------------
In the Master I wrote:
--------------------------------------------------------------------
DO
··· SERIN si\fc, baud, [com]········ ' receive one byte
··· DEBUG com······················· ' display on screen
· LOOP UNTIL com = 10
· DEBUG cr, "Press any key to continue", cr
· DEBUGIN com
· GOTO start
---------------------------------------------------------------------
The Master receives and displays:
---------------------------------------------------------------------
Communication established
You are clear to send
---------------------------------------------------------------------
And all of this takes only a one-byte variable!· I could have sent/received an unlimited number of byte(depending on memory available) until the Slave transmission was terminated with a " 10 ".· The Master looks for a " 10 " in the DO/LOOP, which tells it to terminate the received string.
Try it - it really saves variable space.
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Don't have VGA?
Newzed@aol.com (mailto:Module?Newzed@aol.com)
·
serstring· VAR· byte(24)
used up almost all of my variable space.· So I looked for another alternative - the DO/LOOP routine.· Now when I send an "A" to the Slave, it sends back:
---------------------------------------------------------------------
SEROUT so\fc, baud, ["Communication OK", 13, "You are clear to send",13,10]
---------------------------------------------------------------------
In the Master I wrote:
--------------------------------------------------------------------
DO
··· SERIN si\fc, baud, [com]········ ' receive one byte
··· DEBUG com······················· ' display on screen
· LOOP UNTIL com = 10
· DEBUG cr, "Press any key to continue", cr
· DEBUGIN com
· GOTO start
---------------------------------------------------------------------
The Master receives and displays:
---------------------------------------------------------------------
Communication established
You are clear to send
---------------------------------------------------------------------
And all of this takes only a one-byte variable!· I could have sent/received an unlimited number of byte(depending on memory available) until the Slave transmission was terminated with a " 10 ".· The Master looks for a " 10 " in the DO/LOOP, which tells it to terminate the received string.
Try it - it really saves variable space.
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Don't have VGA?
Newzed@aol.com (mailto:Module?Newzed@aol.com)
·