PDA

View Full Version : Can't WAIT



MOUNTAIN747
- 30th January 2014, 00:23
Hi Guys,
I’m using PBP 2.60 & MPLAB doing some RS485 between two PIC’s. The WAIT function of HSERIN will not work. If I follow HSERIN with str it immediately high lite STR and compiles fine. When I type wait, it does not high lite and if I compile I get an ERROR… EXPECTED “]”.There is no problem with the bracket. Without the wait function it compiles fine. If I type waitstr, nothing high lites and I get the same error. The BOOK says HSERIN should support this WAIT function. What have I missed?

Wayne

Darrel Taylor
- 30th January 2014, 00:51
Highlighting is done by MPLAB for a version of basic other than pbp.
Just because it doesn't highlight doesn't mean anything.

Since both WAIT and WAITSTR work fine in HSEROUT, you will need to post your code that does not compile.

MOUNTAIN747
- 30th January 2014, 01:35
Hi Darrel,
The program compiles fine with this statement:
HSERIN [STR Ser_data\8\”$”]

but does not compile with:
HSERIN [waitstr Ser_data\8\”$”]

I’ve almost decided I have some damaged code in PBP and may need to reload.
This function is on the master. I need for the slave to respond after it has received and carried out a command from the master. The master is stopping on this HSERIN command and I think it is timing out because the slave is sending the “all done” after command is carried out but the master doesn’t seem to see it.
I am using your Interrupts on the slave but I’m not sure how to implement this on the master as it must move to the next program line after HSERIN. If I wait for the slave’s response in a wait loop on the master, then catch the interrupt on the master, the master would go back to the wait loop on INT_RETURN. Is there any way to pop the stack, set INT bits, and do a GOTO out of the INTERRUPT? I’m at a loss here.
Thanks,
Wayne

Darrel Taylor
- 30th January 2014, 02:19
Without the \"$", it will compile.
You only specify the length to match. There is no optional terminating character.

But, I think maybe there's some confusion about what WAITSTR does ...
It waits until it receives a string of text that matches the contents of the specified array.

If you want it to wait for "all done", you first have to load the array with the text.

ARRAYWRITE Ser_data,["all done"]
HSERIN [waitstr Ser_data\8]

If you want the "$" in there too, you just add it to the string ...

ARRAYWRITE Ser_data,["all done$"]
HSERIN [waitstr Ser_data\9]

If it never receives "all done$", it will never exit the command unless you add a timeout.

MOUNTAIN747
- 30th January 2014, 02:50
Yep! It compiled. You are right (as always) I didn't understand exactly how the WAITSTR functions. I get it now. I'll test this out tomorrow. Thanks Darrel,

Wayne

Darrel Taylor
- 30th January 2014, 03:48
And I'll add that WAITSTR allows you to change the string to match at Run-Time.

If you will always be waiting for "all done", use WAIT("all done") instead.