reset a variable
Archiver
Posts: 46,084
I'm using SERIN command to get data from outside and put it in a
variable. I just want to know how to purge the contents of this
variable when the job is done.
For now, I load $00 in each byte of the variable, and have problems
with this method.
Another question. Is it possible to monitor (SERIN) an input when
continuing executing a program.
I have a program that runs but have to wait for a reset command. With
the SERIN, program halts since a data arrive from the reset command
and the program doesn't run until that.
Thank you.
Wally
variable. I just want to know how to purge the contents of this
variable when the job is done.
For now, I load $00 in each byte of the variable, and have problems
with this method.
Another question. Is it possible to monitor (SERIN) an input when
continuing executing a program.
I have a program that runs but have to wait for a reset command. With
the SERIN, program halts since a data arrive from the reset command
and the program doesn't run until that.
Thank you.
Wally
Comments
put 0 manually into the variable. What problems are you having,
specifically?
SERIN is a "blocking" function. While waiting for on SERIN the program
cannot do anything else. Depending on your outside source, you could user
flow control to improve performance. Even without flow control, you can use
the timeout parameter so that you don't "stick" on a SERIN too long.
The manual and help file cover these things in detail.
-- Jon Williams
-- Parallax
In a message dated 5/15/2003 12:55:49 PM Central Standard Time,
wally2117@y... writes:
> I'm using SERIN command to get data from outside and put it in a
> variable. I just want to know how to purge the contents of this
> variable when the job is done.
>
> For now, I load $00 in each byte of the variable, and have problems
> with this method.
>
> Another question. Is it possible to monitor (SERIN) an input when
> continuing executing a program.
>
> I have a program that runs but have to wait for a reset command. With
> the SERIN, program halts since a data arrive from the reset command
> and the program doesn't run until that.
>
> Thank you.
> Wally
[noparse][[/noparse]Non-text portions of this message have been removed]
It only does one thing at a time, and when
waiting in a SERIN, SERIN is that thing.
There is an excellent PIC-based co-processor app in
these pages somewhere which dynamically configures a
PIC to capture data for you while your BS2 does
something else. And, the MAX3110 provides another
chip-based 8-byte FIFO approach.
Having said that, you can simulate multi-tasking
by having a time-out on your SERIN, quickly
checking your reset bit, then going back to
wait on the SERIN some more.
And I don't understand the problem of the
'purged variable'. What's wrong with setting
it to 0? Why can't you just ignore the old
value? Note you can assign 'aliases' to
VARs, which may speed up clearing them
slightly.
--- In basicstamps@yahoogroups.com, "wally2117" <wally2117@y...>
wrote:
> I'm using SERIN command to get data from outside and put it in a
> variable. I just want to know how to purge the contents of this
> variable when the job is done.
>
> For now, I load $00 in each byte of the variable, and have problems
> with this method.
>
> Another question. Is it possible to monitor (SERIN) an input when
> continuing executing a program.
>
> I have a program that runs but have to wait for a reset command.
With
> the SERIN, program halts since a data arrive from the reset command
> and the program doesn't run until that.
>
> Thank you.
> Wally
in a PC serial port with the stamp.
Here how it works.
When first running the software, it asks the pc port for a control
panel plugged in. The basic stamp has to answer the questions of the
software. After that (initialization of the software) the stamp waits
for contact closure to start some applications in the software. This
part is working very well.
Where the things are complicated, is when I close and restart the
software as the stamp is still waiting for software contact closure.
In the contact closure routine,I included the initialization routine.
gpi:
input 7 the pin waiting for the contact closure,
if in7 = 0 then play function that do when the contact close
serin, baud, (buffer\16) wait for a software restart, buffer is
the starting question of the
software.
if buffer\3 = $5e then init if the soft ask the question then
re-initialize to do the opening routine.
goto gpi
You can see that the gpi routine halts at the serin line. I've added a
time out to the serin command. It wants to work sometime but the
buffer in the debug window shows lots of data coming from the software
as it continuously talks on the serial port. I've also added lines to
clear buffer like buffer\0 = $00
buffer\1 = $00 and so on till buffer\15 just before the serin line. It
don't works as well.
The way I found to resolve the bug is adding a reset switch on my
project and press the button just before starting the software but I
would avoid to press a button and want to have it done by the basic stamp.
Thanks for your help.
Wally
--- In basicstamps@yahoogroups.com, "wally2117" <wally2117@y...> wrote:
> I'm using SERIN command to get data from outside and put it in a
> variable. I just want to know how to purge the contents of this
> variable when the job is done.
>
> For now, I load $00 in each byte of the variable, and have problems
> with this method.
>
> Another question. Is it possible to monitor (SERIN) an input when
> continuing executing a program.
>
> I have a program that runs but have to wait for a reset command. With
> the SERIN, program halts since a data arrive from the reset command
> and the program doesn't run until that.
>
> Thank you.
> Wally
If you toggle DTR on your serial port (programatically from the
software running on your PC) it will reset your Stamp program to the
beginning with all variables cleared to zero.
Regards,
Steve
I've written a short SERIN Timeout demo, and uploaded it
to the 'Files' area on groups.yahoo.com/group/basicstamps.
It's in 'AlDir\SerinTimeoutDemo.bs2'.
It uses the Debug port to show where the program is,
and reads from the Debug window to allow you to put
in your reset messages.
--- In basicstamps@yahoogroups.com, "wally2117" <wally2117@y...>
wrote:
> My problem is that I simulate a control panel for a specific
software
> in a PC serial port with the stamp.
>
> Here how it works.
>
> When first running the software, it asks the pc port for a control
> panel plugged in. The basic stamp has to answer the questions of the
> software. After that (initialization of the software) the stamp
waits
> for contact closure to start some applications in the software. This
> part is working very well.
>
> Where the things are complicated, is when I close and restart the
> software as the stamp is still waiting for software contact closure.
>
> In the contact closure routine,I included the initialization
routine.
>
> gpi:
> input 7 the pin waiting for the contact closure,
> if in7 = 0 then play function that do when the contact close
> serin, baud, (buffer\16) wait for a software restart, buffer
is
> the starting question of
the
> software.
> if buffer\3 = $5e then init if the soft ask the question
then
> re-initialize to do the opening routine.
> goto gpi
>
>
> You can see that the gpi routine halts at the serin line. I've
added a
> time out to the serin command. It wants to work sometime but the
> buffer in the debug window shows lots of data coming from the
software
> as it continuously talks on the serial port. I've also added lines
to
> clear buffer like buffer\0 = $00
> buffer\1 = $00 and so on till buffer\15 just before the serin line.
It
> don't works as well.
>
> The way I found to resolve the bug is adding a reset switch on my
> project and press the button just before starting the software but I
> would avoid to press a button and want to have it done by the basic
stamp.
>
> Thanks for your help.
> Wally
>
> --- In basicstamps@yahoogroups.com, "wally2117" <wally2117@y...>
wrote:
> > I'm using SERIN command to get data from outside and put it in a
> > variable. I just want to know how to purge the contents of this
> > variable when the job is done.
> >
> > For now, I load $00 in each byte of the variable, and have
problems
> > with this method.
> >
> > Another question. Is it possible to monitor (SERIN) an input when
> > continuing executing a program.
> >
> > I have a program that runs but have to wait for a reset command.
With
> > the SERIN, program halts since a data arrive from the reset
command
> > and the program doesn't run until that.
> >
> > Thank you.
> > Wally