well, fact is, that often messages are dropped (or get corrupted).
e.g., the master tells the slave to start a motor and during this action the master *should* wait until a touch sensor on the slave is pressed by a motorized arm (e.g., claw completely down).
if the touch sensor on the slave is pressed, the slave *should* send this "button pressed message" back to the master.
the master *should* get this message and *should* proceed with the following program comands
(e.g., tell the slave to close the claw&grab piece, then move claw up (until other sensor pressed), then move arms to a certain square (until certain encoders are reached), then lower the claw (until sensor pressed), then open the claw&release piece, then claw up (until other sensor pressed) and wait for next move cmd... ).
it sounds easy, and (spoken for the chess progam), 3 or 4 or 5 plys are executed correctly, sometimes more, sometimes less.
But suddenly e.g. the claw moves down and grabs the piece, but then the slave doesn't react any more, it doesn't move up or anything, although the sensor states of the slave can be monitored correctly on the master's display. But the master seems to wait for any slaves's reaction, and as he don't get it (completely), he freezes, too (except the "DisplayValues task").
The only explanation I have is, some special BT command was not transmitted correctly or hasn't been read correctly.
So I intended to check by sort of "in-process-control" and a "feed-back" what was sent and what has been received.
Anything is definetly going wrong in this BT thing.
In case the master sends a cmd to the slave the error check is working well.
So the mistake must happen to the BT cmds sent from the slave to the master:
Now what should I do?
Code: Select all
#define BT_CONN 0
#define INBOX 1 // requests (motor ctrl, variables)
#define OUTBOX_1 2 // sensors (out string sending continuously)
#define OUTBOX_2 3 // return ack
int checksum(string s) {
int cs=0;
for (int i=0;i<strlen(s);++i) cs+=s[i];
return cs;
}
//...
string out="1234567890test";
int check;
check=checksum(out);
do {
SendResponseString(OUTBOX_1, out);
// <<<<<<<<<<<< ?
// <<<<<<<<<<<< ?
// how to check if the out string
// was transmitted correctly to the master,
// has been received completely by the master,
// and has been read correctly by the master ?
// (feed-back ?)
// <<<<<<<<<<<< ?
// <<<<<<<<<<<< ?
}
Wait(10);