Serin + timeout never wait, jump directly on 8.0.1.3 beta

Hi,

I need serin + timeout to wait ACKs from motor controler.

If the motor controler don’t send the ACK or if data is corrupt, the timeout is very important, else program stop and robot crash:s

program init vd and vg and gosub to :

moteurs

serout poutm, bm, "v01 ", sdec vg, 13, 10]
serin pinmg, bm, 10000, labeltimeout, [wait(10)] ’ Same problem with any duration, bauds or modifiers etc.
serout poutm, bm, "v02 ", sdec vd, 13, 10]
serin pinmd, bm, 10000, labeltimeout, [wait(10)]
labeltimeout ’ Jump directly here, never wait 10000ms:(

return

I use :

  • last 8.0.1.3 beta
  • timer interrupt (timerwint_imiea + gra = 20000 I disable interrupt when I use serin or serout) -> all OK
  • hserial with 0 timeout for tcp server (byte per byte) -> all OK

I try older IDE version and post here…

Please help,
Pascal

You are not using the serin command properly.

You should have something like:

serin poutm, bm, 1000, labletimeout, <variables to hold input data here>]

8-Dale

I write 10000ms for sample, I need 100ms (extreme maximum time of write EEPROM ACK)

Samples:

firstanybyte var byte
serin p10, i19200, 1000, timeout, [firstanybyte]
timeout 'Problem : jump directly here, no 1000ms wait.


chaine var byte(4)
serin p10, i19200, 1000, timeout, [chaine\4\10]
timeout 'Problem : jump directly here, no 1000ms wait.


serin p10, i19200, [wait(10)] ’ LF part of CR-LF work good on test but if motor controler bug or is down -> program crash

On 8.0.0.0 I remember, timeout for serin work good…

Pascal

This is still wrong. Are you epecting a 10ms timeout? You need to do it like I showed or you are not going to get the results you want.

Are you using a Basic Atom or an Atom PRO?

8-Dale

I use BASIC AtomPro 28 pin (on Bot Board).

wait(10) modifier wait for byte = 10. work without serin timeout.

serin p10, i19200, [wait(10)] = Wait for Line Feed from motor controler.
WORK
But dont work with serin timeout…

'serout Read register to motor controler…
serin p10, i19200, [dec motorcontrolerregister] 'and wait for answer
WORK
But dont work with serin timeout…

SERIN timeout work very good on 8.0.1.0 -> it’s a bug on 8.0.1.3b ! Need test on 8.0.1.2b if someone is interested…

hserin [dec function, dec pterm, dec iterm, dec dterm, dec pidscalar, dec pwmlimit]
serout poutm, bm, "s01 03 ", dec function, 13, 10]
serin pinmg, bm, 100, timeoutr, [reponse]
serout poutm, bm, "s02 03 ", dec function, 13, 10]
serin pinmd, bm, 100, timeoutr, [reponse]
serout poutm, bm, "s01 04 ", dec pterm, 13, 10]
serin pinmg, bm, 100, timeoutr, [reponse]
serout poutm, bm, "s02 04 ", dec pterm, 13, 10]
serin pinmd, bm, 100, timeoutr, [reponse]
serout poutm, bm, "s01 05 ", dec iterm, 13, 10]
serin pinmg, bm, 100, timeoutr, [reponse]
serout poutm, bm, "s02 05 ", dec iterm, 13, 10]
serin pinmd, bm, 100, timeoutr, [reponse]
serout poutm, bm, "s01 06 ", dec dterm, 13, 10]
serin pinmg, bm, 100, timeoutr, [reponse]
serout poutm, bm, "s02 06 ", dec dterm, 13, 10]
serin pinmd, bm, 100, timeoutr, [reponse]
serout poutm, bm, "s01 08 ", dec pidscalar, 13, 10]
serin pinmg, bm, 100, timeoutr, [reponse]
serout poutm, bm, "s02 08 ", dec pidscalar, 13, 10]
serin pinmd, bm, 100, timeoutr, [reponse]
serout poutm, bm, "s01 25 ", dec pwmlimit, 13, 10]
serin pinmg, bm, 100, timeoutr, [reponse]
serout poutm, bm, "s02 25 ", dec pwmlimit, 13, 10]
serin pinmd, bm, 100, timeoutr, [reponse]

goto finr

timeoutr
serout poutvfd, bvfd, [12, “Erreur ! Timeout PID.”]
vfdpointeur = 0

finr

Pascal

serin timeout OK on 8.0.1.2b

So it sounds like he (Acidtech) broke it between his 8.0.1.2 and 8.0.1.3 releases. I believe this is the time that he reworked part of the serin command to make serial flow control work. Hopefully it is an easy thing for him to fix and release a new beta.

Kurt

The problem is the wait command is going to continue waiting until the correct data is received. The timeout will only timeout if NO data is received. If anything else is being received the wait command will wait and the timeout will be reset. So until either the wait command gets the correct byte or no data is recevied for 10ms the serin command will continue to run. To do what you want you need to read each byte received with a timeout(so if no data is received you don’t get stuck) and check it with an if-then. Something like this:

tryagain serin pin,baudmode,10000,timeoutlabel,[data] if(data<>10)then tryagain

The problem is same on empty or pulled down/up Pin.
The problem is same without “wait” modifier
On 8.0.1.3 serin+timeout = goto! Never read data…

SOLVED :

lynxmotion.net/viewtopic.php?t=3109