Serin & serout
Archiver
Posts: 46,084
Hi All,
I wrote a C program to send commands to the stampII.
The stamp should then respond to the commands. For
example C program sends "*SN\r\n" the stamp should
reply with "SN=12345".
Ok now the problem is that the stamp seems te echo
back the command before the reply. It first sends
"*SN\n" and then "SN12345". (I just want the
"SN12345")
I am using pin 16 for both serin and serout. Why
does this happen? Will it always happen?
How can I prevent this.
=============================================
Code:
Serial Data "SN12345",0
Start Var Byte
Init :
SerIn 16,16468,[noparse][[/noparse]Str Serstr\10\cr]
if SerStr(0) <> "*" Then INIT
Gosub Choice
Return
Choice :
If SerStr (1) = "S" Then ShowSerial
If Serstr (1) = "V" Then ShowVersion
Return
Both ShowSerial and ShowVersion just routines that
sends a string out with Serout.
But before the program can get to choice the "*S\r\n"
is echoed back.
Thanks for You Help
Danie
__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.com/
I wrote a C program to send commands to the stampII.
The stamp should then respond to the commands. For
example C program sends "*SN\r\n" the stamp should
reply with "SN=12345".
Ok now the problem is that the stamp seems te echo
back the command before the reply. It first sends
"*SN\n" and then "SN12345". (I just want the
"SN12345")
I am using pin 16 for both serin and serout. Why
does this happen? Will it always happen?
How can I prevent this.
=============================================
Code:
Serial Data "SN12345",0
Start Var Byte
Init :
SerIn 16,16468,[noparse][[/noparse]Str Serstr\10\cr]
if SerStr(0) <> "*" Then INIT
Gosub Choice
Return
Choice :
If SerStr (1) = "S" Then ShowSerial
If Serstr (1) = "V" Then ShowVersion
Return
Both ShowSerial and ShowVersion just routines that
sends a string out with Serout.
But before the program can get to choice the "*S\r\n"
is echoed back.
Thanks for You Help
Danie
__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.com/
Comments
you have the data in and data out lines from your PC both going to the stamp's
I/O 16. If so, your PC is probably talking to itself. Test this theory by
removing power to the stamp. I bet you get the same "echo" behavior. My
suggestion on a fix is to use any of the I/O pins 0-15 as the input (with an
in-line limiting resistor as recommended in the manual). Then use 16 as your
output, as it comes closer to the 232 levels. Good luck.
Clark Hughes
didv wrote:
>
> Hi All,
>
> I wrote a C program to send commands to the stampII.
> The stamp should then respond to the commands. For
> example C program sends "*SN\r\n" the stamp should
> reply with "SN=12345".
>
> Ok now the problem is that the stamp seems te echo
> back the command before the reply. It first sends
> "*SN\n" and then "SN12345". (I just want the
> "SN12345")
>
> I am using pin 16 for both serin and serout. Why
> does this happen? Will it always happen?
> How can I prevent this.
>
> =============================================
> Code:
>
> Serial Data "SN12345",0
> Start Var Byte
>
> Init :
> SerIn 16,16468,[noparse][[/noparse]Str Serstr\10\cr]
> if SerStr(0) <> "*" Then INIT
> Gosub Choice
> Return
>
> Choice :
> If SerStr (1) = "S" Then ShowSerial
> If Serstr (1) = "V" Then ShowVersion
>
> Return
>
> Both ShowSerial and ShowVersion just routines that
> sends a string out with Serout.
>
> But before the program can get to choice the "*S\r\n"
> is echoed back.
>
> Thanks for You Help
> Danie