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;
 }
 }
}
dda
1,5951 gold badge12 silver badges17 bronze badges
asked Aug 27, 2017 at 15:36
2
  • What protocol does your "host" use? Commented Aug 27, 2017 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? Commented Aug 28, 2017 at 5:48

1 Answer 1

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.

answered Aug 28, 2017 at 12:33
17
  • Thank you, I already did that. But only trash arrives at the receiver-side. Commented Aug 28, 2017 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? Commented Aug 28, 2017 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. Commented Aug 28, 2017 at 15:41
  • This is what I tried: ether.sendUdp(buf, 256, srcPort, hostip, dstPort); Commented Aug 28, 2017 at 15:41
  • And you are sure that buf contains that JFIF header at the point of sending? Commented Aug 28, 2017 at 15:44

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.