Hi
Thank for the reply.
I am using java.comms package to communicate with microcontroller.
Yes my problem is with protocol.
I can read a single byte and send a byte but i have problems with reading loads of byte being sent at once. The data that are sent from microcontroller are image data that come from camera i connected to microcontroller so there is loads of data.
while(true){
System.out.println("Enter command");
while(in.hasNextInt()){
i = in.nextInt();
byte b = (byte)i;
a.UARTputc(b); //send command
byte s = a.UARTgetb(); //check if something came back
System.out.println(s); //for debug
if(s == 119){ //start of picture ascci for 'w'
do{
temp = a.UARTgetb();
pic[count] = temp;
count++;
System.out.println(count); //for debug
}while(temp != 10);//ascii for '\n'
this part i have now does not even get into the do-while loop
This is for reading the port:
case SerialPortEvent.DATA_AVAILABLE:
readBuffer = new byte[8];
try {
while (inputStream.available() > 0) {
int numBytes = inputStream.read(readBuffer);
}
int byteCount = 0;
for (int i = 0; i < currentWrite.length; i++) {
if (currentWrite[i] == readBuffer[i]) {
byteCount++;
}
}
if (byteCount != currentWrite.length) {
dataIn = true;
}
} catch (IOException e) {System.out.println(e);}
break;
}
public void UARTputc(byte b) throws Exception{
byte[] data = {b};
sPort.write(data);
utils.pause(100);
}
public byte UARTgetb(){
byte t=0;
byte b[] = sPort.read();
t = b[0];
return t;
}
Any advice is appreciated
Regards