Data sendback over ethernet from mbed
Dependencies: EthernetInterface FastAnalogIn mbed-rtos mbed
Fork of Ananlog_in_test by
Revision 1:27168b548705, committed 2014-10-24
- Comitter:
- apullin
- Date:
- Fri Oct 24 23:05:27 2014 +0000
- Parent:
- 0:e066babe3c39
- Commit message:
- Fixes to memory copy and pointers.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r e066babe3c39 -r 27168b548705 main.cpp --- a/main.cpp Tue Oct 21 19:53:05 2014 +0000 +++ b/main.cpp Fri Oct 24 23:05:27 2014 +0000 @@ -11,15 +11,18 @@ const int BROADCAST_PORT = 58083; -struct packet{ +typedef struct{ int times[512]; uint16_t samples1[512]; uint16_t samples2[512]; uint16_t samples3[512]; uint16_t samples4[512]; -}; +} packet_t; int main() { + + packet_t sample_data; + //Setting up the Ethernet EthernetInterface eth; eth.init(); //Use DHCP @@ -37,7 +40,6 @@ t.reset(); t.start(); while(1){ - packet sample_data; printf("Executing Read Loop"); for(int i=0; i<512; i++) { sample_data.times[i] = 6; @@ -55,14 +57,15 @@ printf("Size of struct: %i \n", sizeof(sample_data)); printf("Copying to char array \n"); - char* data = static_cast<char*>(static_cast<void*>(&sample_data)); - //unsigned char *out_buffer = (char*) &sample_data; + //char* data = static_cast<char*>(static_cast<void*>(&sample_data)); + char *out_buffer = (char*)(&sample_data); - char out_buffer[6144]; - memcpy(&out_buffer,&data,sizeof(packet)); + //char out_buffer[6144]; + //memcpy(out_buffer, data, sizeof(sample_data)); //out_buffer[6144] = '\0'; printf("Sending to Ethernet \n"); - sock.sendTo(broadcast, out_buffer, sizeof(out_buffer)); + //sock.sendTo(broadcast, out_buffer, sizeof(out_buffer)); + sock.sendTo(broadcast, out_buffer, 6144); } } \ No newline at end of file