0

How do I transfer a series of byte[256]-buffers to a server with an ENC28J60 Ethernet adapter? I get blocks of uint8_t from an Arducam camera module and I'd like to transfer them to a host. Does somebody have an idea how to solve that? I asked a previous question regarding that topic but now new issues arrived.

This is how the array is filled:

uint8_t temp = 0, temp_last = 0;
byte buf[256];
length = myCAM.read_fifo_length();
while (length--) {
  temp_last = temp;
  temp =  SPI.transfer(0x00);
  if ((temp == 0xD9) && (temp_last == 0xFF)) {
    buf[i++] = temp;
    is_header = false;
    i = 0;
  }
  if (is_header == true) {
    //Write image data to buffer if not full
    if (i < 256)
      buf[i++] = temp;
    else {
      i = 0;
      buf[i++] = temp;
    }
  }
}
  • What protocol does your "host" use? – Majenko Aug 27 '17 at 18:33
  • UDP, too. But probably I'm bad at writingn a proper receiver. Do you have an advice how this could look like? – goetzmoritz Aug 28 '17 at 5:48
0

Assuming you are using the EtherCard library you can send a UDP packet with:

ether.sendUdp(packet_data, length, srcPort, hisip, dstPort );   

Assuming you have already set up your source port and have the destination IP address and port in hisip and dstPort.

The prototype for the function is:

void sendUdp (char *data,uint8_t len,uint16_t sport, uint8_t *dip, uint16_t dport);

The example udpClientSendOnly.ino with the library shows you UDP sending in action.

  • Thank you, I already did that. But only trash arrives at the receiver-side. – goetzmoritz Aug 28 '17 at 15:33
  • How do you know it is trash? Have you examined the actual data you are getting from the camera to make sure that you are actually sending what you think you are sending? – Majenko Aug 28 '17 at 15:35
  • Yes, when I look at my console on arduino-side I get eg the JFIF-header. But when I make a plain plot of the incoming data from UDP than I cannot find that certain header. – goetzmoritz Aug 28 '17 at 15:41
  • This is what I tried: ether.sendUdp(buf, 256, srcPort, hostip, dstPort); – goetzmoritz Aug 28 '17 at 15:41
  • And you are sure that buf contains that JFIF header at the point of sending? – Majenko Aug 28 '17 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.