try {
while (inputStream.available() > 0) {
if (readBuffer == 0x11){//javilen requests stuff
if (st.hasMoreTokens()){
outputStream.write(0x12); //send 0x12
if (index == cmdlen){
outputStream.write(0x0D); //send CR
index++;
}
else if (index == cmdlen + 1) {
outputStream.write(0x0A); //send LF
cmd = false;
index = 0;
cmdlen = 0;
}
else { · outputStream.write(st.nextToken()); //send data byte · index++;
}
But you really must implement the whole state machine as in my code.
The javelin may transmit 0x11 inside <messagedata> (see protocol description)
which in that case IS NOT A REQUEST for data. Also remember that anything that
the PC transmits to the Javelin, is immediately echoed back to the PC.
well the program that i am writing only reads the input stream if it equals 0x11 if the control signal is echoed back it would be 0x12 (byte) so it would disreguard it. You said however that the javelin may transmit 0x11 in the middle of message data. Is there any way to fix this problem I was thinking maybe having another tokenizer set on the input to search for 0x11 would this work? I am assuming that if it transmits 0x11 in the message data then it won't be recognized by the program.-Adam
ok well i have set up the javelin so that it never transmits any data that i know of unless if it echoes the message sent to it. The control signals to the stamp are chars such as a, s, d, f and the like and are separated by the program using a string tokenizer and then transmitting them separately with 0x11 in front of them. I tried to setup the dataflow one way so that the data goes to the javelin and not back but as you said previously it echoes the commands. Can the request from the stamp get embedded in the echo so that I would need a tokenizer on the inputstream to identify 0x11? Thanks!-Adam
Comments
try {
while (inputStream.available() > 0) {
if (readBuffer == 0x11){//javilen requests stuff
if (st.hasMoreTokens()){
outputStream.write(0x12); //send 0x12
if (index == cmdlen){
outputStream.write(0x0D); //send CR
index++;
}
else if (index == cmdlen + 1) {
outputStream.write(0x0A); //send LF
cmd = false;
index = 0;
cmdlen = 0;
}
else {
· outputStream.write(st.nextToken()); //send data byte
· index++;
}
But you really must implement the whole state machine as in my code.
The javelin may transmit 0x11 inside <messagedata> (see protocol description)
which in that case IS NOT A REQUEST for data. Also remember that anything that
the PC transmits to the Javelin, is immediately echoed back to the PC.
regards peter
·
try {
···················· while (cmd==true) {
···················· while (input.hasMoreTokens()) {
····· token = input.nextToken();
····· if (token == 0x11) {
········ break;
········ }
try {
···· while (input.hasMoreTokens()) {
······· token = input.nextToken();
······· if (token == 0x11) {
········· if (cmd==true) {
··········· ·break; //send 0x12,CR or 0x12,LF or 0x12,databyte
··········}
········· else {
··········· break; //send 0x13
········· }
······· }
····· }
·}
but ONLY and ONLY if you never transmit 0x11 inside a message AND your PC
program never responses with a databyte· value 0x11.
regards peter
Only data send by pc to the javelin gets echoed back to the pc.
regards peter
But you said you only transmit letters like d,f etc. so
no problem there.
regards peter