Hi there,
first of all, I wish everybody a happy new year.
Then here's the problem I face using a brand new Netduino+2 using this firmware version "Netduino 4.2.1.2" the problem was the same when I was using the 4.2.1.0 firmware version.
I'm trying to communicate with a linksprite TTL camera (see http://www.linksprit...p?id=15&lang=en). When using an arduino the camera works well, apart from the fact that it is damn slow. I was thus hoping to get a substantial speed improvement using a Netduino+2.
When using the library available on tinyclr here : http://www.tinyclr.c...share/entry/165 I first notice that the code has to be slightly modified so that the method ReadAllRemaining() works properly (original version throws an exception when reading bytes that are not available, which is strange considering the problem I have). Below, the modified version of this method. Apart from some debug.print added in the Read and Write methods, the rest of the LinkspriteCamera class remains unchanged:
private void ReadAllRemaining(){ int toRead = port.BytesToRead() while (toRead > 0) { Read(junkBuffer, toRead); }}
My problem lies during the actual reading of JPEG data in the method below:
public void GetPicture(ActionBytes bytesAction) { Send(SNAP_COMMAND); if (LookFor(SNAP_OK_RESPONSE)) { Send(SIZE_COMMAND); if (LookFor(SIZE_OK_RESPONSE)) { //MSB, LSB var sizeBytesLength = Read(2); int fileSize = (InBuffer[0] << 8) | InBuffer[1]; int startAddress = 0; int bytesRead = 0; GET_CHUNK_COMMAND[12] = MSB(IN_BUFFER_SIZE); GET_CHUNK_COMMAND[13] = LSB(IN_BUFFER_SIZE); bool endReached = false; while (!endReached) { GET_CHUNK_COMMAND[8] = MSB(startAddress); GET_CHUNK_COMMAND[9] = LSB(startAddress); Send(GET_CHUNK_COMMAND); ///////////////////////////////////////////////////////////////// // Problem lies during the read operation triggered by this call to LookFor ///////////////////////////////////////////////////////////////// if (LookFor(GET_CHUNK_OK_RESPONSE)) { int chunkLength = 0; do { chunkLength = Read(); //ditch footer Read(junkBuffer, GET_CHUNK_OK_RESPONSE.Length); //publish byte data if (chunkLength > 0) { bytesRead += chunkLength; if (bytesRead >= fileSize) { endReached = true; chunkLength = FindEnd(chunkLength); } bytesAction(NewArray(chunkLength)); } startAddress += chunkLength; } while (!endReached && chunkLength > 0); } } } } }
The problem is that the read that occurs after the sending of the GET_CHUNK_COMMAND command bytes array during the read operation that follows seems to block forever waiting for some bytes to come from the camera.
Any idea why this happen ? Feel free to ask if you need the full source code to be posted.
Thanks in advance for your guidance.
Benoît