SERRXD problem

cravenhaven

Senior Member
I have tried a couple of options to get this working properly but still have issues.

First attempt worked in simulator but skipped several inputs on the chip. eg I typed in the value 11 and the next few lines would execute down to Hours. I assumed this meant it was a keybounce response (somehow receiving multiple ENTERs).
Code
SERTXD(CR,LF,"Type in current year eg 11")
SERRXD[20000],Year
SERTXD(CR,LF,"Type in current month number eg 08 for August")
SERRXD[20000],Month
SERTXD(CR,LF,"Type in current Day of Month eg 25")
SERRXD[20000],Day
SERTXD(CR,LF,"Type in current Hour eg 17 for 5pm")
SERRXD[20000],Hours
SERTXD(CR,LF,"Type in current Minutes eg 57")
SERRXD[20000],Mins
SERTXD(CR,LF,"Type in current Seconds eg 43")
SERRXD[20000],Secs

So I modified it to use a qualifier, but now I have to put in the values twice for each entry. ie y11<ENTER> y11<ENTER>. If I type the value once and wait for the timeout it doesnt accept the value.

Code
SERTXD(CR,LF,"Type in current year eg y11")
SERRXD[20000],("y"),#Year
.
.

Thanks
Allan
 

MPep

Senior Member
Cravenhaven,
Please post your full code so others may try thhis out for themselves.
Cheers.
 

MartinM57

Moderator
You appear to be sending two characters e.g. '1' and '1' for year '11', but only SERRXD'ing one character

So have a play with
Code:
SERTXD(CR,LF,"Type in current year eg 11")
SERRXD[20000],Year[COLOR="#FF0000"][B]Ten, YearUnit[/B][/COLOR]
SERTXD(CR,LF,"Type in current month number eg 08 for August")
SERRXD[20000],Month[COLOR="#FF0000"][B]Ten, MonthUnit[/B][/COLOR]
etc
You will then need to reconstitute the numeric value inside the PICAXE i.e. Year = Year10 * 10 + YearUnit
 

westaust55

Moderator
or try:

Code:
SERTXD(CR,LF,"Type in current year eg 11")
SERRXD[20000],[COLOR="#FF0000"]#[/COLOR]Year
SERTXD(CR,LF,"Type in current month number eg 08 for August")
SERRXD[20000],[COLOR="#FF0000"]#[/COLOR]Month
etc
Optional #&#8217;s are for inputting ASCII decimal numbers into variables, rather than raw characters.
 

cravenhaven

Senior Member
I have tried your suggestions but still have a similar result ie. I have to put in the value twice but it doesnt come out correctly. I have changed the code to take account of Martin57 and Westaust55 suggestions. The output is after a bintoascii conversion (Thanks westaust55).
I also tried using putty as the terminal emulator.

I tried entering; y00,y00,m11,m11,d22,d22,h33,h33,m44,m44,s55,s55
and the result was; y0 ,m187 ,d118 ,h49 ,m236 ,s167

In addition, I cant get it to accept the y/n in the final SERRXD line, I just have to wait for it to time out.

code snippets:
SERTXD(CR,LF,"Type in current year eg y11")
SERRXD ("y"),#TempW0_1,#TempW0_2
Year=TempW0_1*$10+TempW0_2
SERTXD(CR,LF,"Type in current month number eg m08 for August")
SERRXD ("m"),#TempW0_1,#TempW0_2
Month=TempW0_1*$10+TempW0_2
SERTXD(CR,LF,"Type in current Day of Month eg d25")
SERRXD ("d"),#TempW0_1,#TempW0_2
Day=TempW0_1*$10+TempW0_2
SERTXD(CR,LF,"Type in current Hour eg h17 for 5pm")
SERRXD ("h"),#TempW0_1,#TempW0_2
Hours=TempW0_1*$10+TempW0_2
SERTXD(CR,LF,"Type in current Minutes eg m57")
SERRXD ("m"),#TempW0_1,#TempW0_2
Mins=TempW0_1*$10+TempW0_2
SERTXD(CR,LF,"Type in current Seconds eg s43")
SERRXD ("s"),#TempW0_1,#TempW0_2
Secs=TempW0_1*$10+TempW0_2

SERTXD(CR,LF,"Current time in dd/mm/yy hh:mm:ss format is",CR,LF," ")
Temp1=Day
GOSUB Displ_Byte
SERTXD("/")
Temp1=Month
GOSUB Displ_Byte
SERTXD("/20")
Temp1=Year
GOSUB Displ_Byte
SERTXD(" ")
Temp1=Hours
GOSUB Displ_Byte
SERTXD(":")
Temp1=Mins
GOSUB Displ_Byte
SERTXD(":")
Temp1=Secs
GOSUB Displ_Byte

SERTXD(CR,LF,"If the time is ok then press 'y' to continue or 'n' to re-enter")
SERRXD[30000,OW_GetTime],#TempW0_1
IF TempW0_1="n" OR TempW0_1="N" THEN GOTO OW_GetTime

Displ_Byte:
BINTOASCII Temp1,hundr,tens,units ; convert the single byte value into three ASCII character values
IF hundr = "0" THEN ; apply leading blanking
hundr = " "
SERTXD (" ") ; insert an extra space to keep bytes values better right justified
IF tens = "0" THEN
tens = " "
SERTXD (" ")
ENDIF
ENDIF

SERTXD( hundr, tens, units, " ")
RETURN



Output:
Type in current year eg y11
Type in current month number eg m08 for August
Type in current Day of Month eg d25
Type in current Hour eg h17 for 5pm
Type in current Minutes eg m57
Type in current Seconds eg s43
Current time in dd/mm/yy hh:mm:ss format is
118 /187 /20 0 49 :236 :167
If the time is ok then press 'y' to continue or 'n' to re-enter
Type in current year eg y11
 

hippy

Senior Member
I'd suggest using much simpler code until you are comfortable with SERRXD and its various options. Just read a byte or value and print the result, just use one SERRXD and don't use a timeout.

Do
SerTxd( "Input data : " )
SerRxd b0
SerTxd( "Value received = ", #b0, CR, LF )
Loop
 

geoff07

Senior Member
You could simplify/clarify this by having a single input line and a select statement to deal with each input. If your input was 'xd11' for example, serrxd could sync on the x and use the d character for the select variable, and the digits following for the input. E.g. something along these lines ..

do
serrxd ("x"),char1,#char2,#char3
select char1
case "d" ..
case "m" ..
...
case "x" exit 'user has typed xx
endselect
sertxd( display current date and time)
loop
'exit comes here ..

users could then selectively update the data that needed changing and leave correct values unchanged. Less code to debug, fewer bytes to store.
 
Top