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– Majenko2017年08月27日 18:33:56 +00:00Commented 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?goetzmoritz– goetzmoritz2017年08月28日 05:48:18 +00:00Commented Aug 28, 2017 at 5:48
1 Answer 1
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– goetzmoritz2017年08月28日 15:33:35 +00:00Commented 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?Majenko– Majenko2017年08月28日 15:35:58 +00:00Commented 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.goetzmoritz– goetzmoritz2017年08月28日 15:41:21 +00:00Commented Aug 28, 2017 at 15:41
-
This is what I tried: ether.sendUdp(buf, 256, srcPort, hostip, dstPort);goetzmoritz– goetzmoritz2017年08月28日 15:41:50 +00:00Commented Aug 28, 2017 at 15:41
-
And you are sure that
buf
contains that JFIF header at the point of sending?Majenko– Majenko2017年08月28日 15:44:17 +00:00Commented Aug 28, 2017 at 15:44
Explore related questions
See similar questions with these tags.