Serrxd problem.

Hooter

Senior Member
Folks - I have got myself into a loop.

In a previous thread a question was asked regarding Serrxd and Hippy posted a reply which included the following comment:

'SERRXD #variable

Will take a series of "0" to "9" bytes which are converted into a number which is stored in the variable when a terminating non-digit byte is received. So if "6" and "5" then "X" were sent, the variable would hold the value 65.'

My question is:

When including the # in the Serrxd command the digits entered are not displayed - as they are when using just Serrxd.

I need to enter a digit like 123 (one hundred and twenty three) and enter it into a variable but I need to see the individual digits as they are being entered.
I can do this if I omit the # but I only get a single digit per entry.
eg.
Serrxd [10000,timeout], b0
Serrxd [10000,timeout], b1
Serrxd [10000,timeout], b2

This gives me b0 = 1, b1 = 2, b2 = 3.

What I actually need is for b0 to hold 123.

Any help is appreciated as always.
 
Last edited:

Pongo

Senior Member
Serrxd [10000,timeout], b0
Serrxd [10000,timeout], b1
Serrxd [10000,timeout], b2
b0 = b0 * 100
b1 = b1 * 10
b0 = b0 + b1 + b2

But I'm not sure how you intend to "see" the individual numbers.
 

Hooter

Senior Member
Thanks for the response Pongo, I will try it shortly.
The only time I need to see the digits is when they are being entered in a terminal program - Tera Term.
Once they have been entered the program moves on to do other things with the variable (123).
Cheers.
 

hippy

Technical Support
Staff member
When including the # in the Serrxd command the digits entered are not displayed - as they are when using just Serrxd.
I would ask; not displayed by what, and what are you using to send and/or display the digits ?

A terminal emulator is responsible for displaying as typed. Otherwise the PICAXE has to echo the characters or number it has received.

If you need the characters displayed as entered you will either need to enable 'local echo' or will have to receive the characters individually, echo each back as received, and you won't be able to use SERRXD #var.

Don't forget that, as described, with SERRXD # you need to send a non-digit character after sending 123 for the PICAXE to determine the number has been entered.
 

Hooter

Senior Member
Thanks for the response Hippy.
I am using Tera Term to create a menu with 3 options - 1,2,and 3.
After selecting an option you are asked to enter a 3 digit number - 123 - see image below.
As you enter the digits they are displayed so the user gets feedback that he has entered something.
See attached screen shot.
I had it working with the standard Serrxd but couldn't think how to get the three separate digits
to appear in a single variable.
I have used Pongos suggestion with a few extras and it works as expected - partial code below - thanks Pongo.

Code:
SetSiteCode:
sertxd (13,10,"1. Enter Site Code then press enter..",13,10,10)
serrxd [10000, timeout],b0
sertxd (b0)
b0 = b0-48
serrxd [5000, timeout],b1
sertxd (b1)
b1 = b1-48
serrxd [5000, timeout],b11
sertxd (b11)
b11 = b11-48
serrxd [5000, timeout],b10
sertxd (13,10)
b0 = b0 * 100
b1 = b1 * 10
b0 = b0 + b1 + b11
if b0 > 254 then goto exceeded
sertxd (10,13,"New SC is ",#b0,13,10)
goto SaveSC
PicAxeTeraTermCapture.JPG
 
Top