PDA

View Full Version : SERIN bs2px



Doc
04-23-2007, 07:49 PM
Hi everybody,

I·wrote this simple prog for the bs2px :

X VAR Word
SERIN 16, 16572, [DEC X]
DO
· SEROUT 16, 16572, ["Test", CR]
· PAUSE X
·LOOP

It works fine. What I would like to do is that when I enter another value for X in the debug terminal and I press enter, I want that the X get the new value entered.

Any idea please?

Thank you.

Doc

stamptrol
04-23-2007, 08:08 PM
Doc,

Have a look at the DEBUGIN command in the help file. I think it wil give you what you want.

Cheers,

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk

http://www.siskconsult.com
·

Doc
04-23-2007, 11:22 PM
Hey Tom,

I 've already tried to work on DEBUGIN, but did not find anything helpful in this command except that it is a special case of SERIN.

What I am looking for, is that while the prog is running and without interruption, to enter new value of "X" and that this new value could be considered in the Do Loop. I worked with SERIN because I wanted to check how to do if I want to send this new value of X through VB6 MSComm.

Cheers,

Doc

stamptrol
04-23-2007, 11:50 PM
doc,

So, the way you have it now, you get one value for x at the start of the program, but you never go back to get another.

What about putting the serin within the DO-LOOP with a small timeout delay so if no new value is sent, the serout continues.

The term "without interruption" is a bit relative because you don't have a comm buffer to receive data while the program is off doing something else. Technically, the SERIN command stops and waits for data and either receives something as data or times out and moves on.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk

http://www.siskconsult.com
·

Doc
04-24-2007, 01:27 AM
Tom,

I do not think that if SERIN is in the Do...Loop will do the task. The SERIN Timout must be followed with Tlabel; I did try this option, but did not work.

I do not know if we can work on interruption with PBasic, otherwise, I am looking for something like this :

' {$STAMP BS2px}
' {$PBASIC 2.5}

X VAR Word

Main:
SERIN 16, 16572, [DEC X]

DO
· SEROUT 16, 16572, ["Test", CR]
· PAUSE X
LOOP UNTIL "A" is received or anything to interrupt the Do--Loop
GOTO Main

This way the loop will go on until A is sent, then, I can enter a new value of X

Any clue please?

Cheers,
Doc

allanlane5
04-24-2007, 01:37 AM
The BS2 is single tasking. It's Serial I/O is NOT buffered. This means, if you're not waiting in a SERIN statement BEFORE the sender starts sending, you're not going to get the data.

This also means, if you're waiting in a SERIN statement for data, you're not doing anything else. The processor is "Pended", as they say in Unix land -- "Pended", waiting for a "pending" communication. And if the 'sender' never sends, you'll 'pend' forever, unless you use the timeout.

The timeout does let you 'pend' for shorter times than forever. So, if you're going to 'wait' for 'X' anyway, might was well put the 'X' in as your timeout parameter.

But your loop will have to be written:

Main:
DO
SEROUT 16, 16572, [">"] ' A 'prompt'
SERINT 16, 16572, X, Timeout, [DEC InData] ' The DEC modifier takes in an ascill string, translates to word, and puts in InData
TIMEOUT:
Loop Until InData = 10
X = InData
GOTO MAIN

Mike Green
04-24-2007, 01:44 AM
There is no way to interrupt the Stamp by sending it a character and the serial input is not buffered, so the Stamp only examines the input port when it executes the SERIN statement. Anything sent from the PC is ignored otherwise. The only way to do this (and not the way you want) is to use a SERIN with a timeout and put the SERIN in the DO loop. Even so, the SERIN will only see an input character if it is transmitted while the SERIN is actually executing.

The simple answer is that you can't do what you seem to want to do. There are some 3rd party serial input buffers that can attach between a Stamp and a serial input line and the Stamp can read the state of the buffer (whether there is anything present), but that won't work for the DEBUG port. You'd need to use some other I/O pins and you'd need a MAX232 or other TTL to RS232 adapter or a TTL to USB adapter as well.

Doc
04-24-2007, 07:51 PM
OK,

thank you for the info guys.

Cheers,

Doc