View Full Version : Memory Stick Datalogger Demo V1.0
11-11-2009, 01:31 AM
I am trying to see how and where the VAR 'flag' gets set to 0 in the Subroutine 'Check_Drive' in DataLoggerDemoV1.0.bs2.
This is probably a "RTxM" problem on my part, but any help would be good.
11-11-2009, 02:06 AM
If a certain state is reached then the Var flag is set to 1, as this is called the event status flag perhaps this flag is automatically reset by the device after the event and is set to 1 once again when the flag=1 statement is reached again?
this happens with the pink device once the status var is read so i presume the same happens with this one too?
11-11-2009, 02:38 AM
Thanks for the reply.
It looks like 'VAR flag' i s set to 0 by the device during the subroutine 'Get_Data'
and is used to determine a "Connected" condition.
Buffer(0) = "D", Buffer(1) = "D" and flag = 0
I would just like to know how this is done.
It seems to me that a valid response for a "Connected" condition would be if
Buffer(0) = ">" and Buffer(1) = "0"
11-11-2009, 09:04 AM
Hi Marc , the sub routine Check_Drive is a loop looking for a series of events.
A successful series of events·( or at least the beginning and the end of those events·) when a flash drive is plugged in is
1. the logger transmits "DD"·
2. then there is a little more activity which is ignored by the Stamp
3. finally the logger transmits ">"
The Check_Drive loop will detect the device ("DD") when it is plugged in and keep looping until it receives the ">" character .
In the process of detecting the drive the program assigned buffer(0) the value "D" and buffer(1) a value of "D".
Immediately following that line flag is set to 1 , the reason is so that·subsequent Check_Drive loops will now ignore the lines.
ELSEIF buffer(0) = "D" AND buffer(1) = "D" AND flag = 0 THEN
DEBUG "Connected!", CR, "Accessing..."
flag = 1 ' Memory Stick Ready
because until told otherwise buffer (0) and (1) will still contain "DD"
It may or may not be crucial in this instance but is a good example of setting a "flag" to control program flow.
11-11-2009, 11:38 AM
It is clear to me how 'flag' gets set to "1", but I still do not understand how 'flag' gets set to "0".
Could you explain it to me in detail?
Inquiring minds need to know.
11-11-2009, 09:09 PM
variables are initialized to zero at program start
11-12-2009, 08:54 AM
I guess that I came very close to asking a stupid question.
Thanks for your understanding.