I have a problem using the data command. I have been trying to write my own software from scratch and I have been unable to use the device after writing data. After writing the command the either-dream does not send back an ack, and then hangs and stops responding to other commands as well. The only thing that continues to function is the broadcast and from that I see that the point has been added to the buffer. At this point the only way I can get it to work is to cycle the power. Using wireshark I see that it just completely stops responding. Trying to get around this, I also tried sending the begin command after sending the prepare command, which of course was NAKed, and then tried sending data. The data command still didn't receive a response, but after sending this sequence, when responding to any other command, the device only replied back with an Invalid, and echoed back the begin command. The data point was also not added to the buffer. I have tried everything I can think of and would like to get some direction on solving this.
for testing purposes I have the structs for the command defined nearly verbatim from the documentation:
Code:
struct dac_point {
uint16_t control;
int16_t x;
int16_t y;
uint16_t i;
uint16_t r;
uint16_t g;
uint16_t b;
uint16_t u1;
uint16_t u2;
};
struct data_command {
uint8_t command; /* ‘d’ (0x64) */
uint16_t npoints;
struct dac_point data[1];
};
and I am creating a test point to write:
Code:
data_command d;
d.command = 'd';
d.npoints = 1;
d.data[0].x=1000;
d.data[0].y=1000;
d.data[0].control = 0;
d.data[0].g = 0;
d.data[0].b = 0;
d.data[0].i = 0;
d.data[0].r = 0;
d.data[0].u1 = 0;
d.data[0].u2 = 0;
I am using winsocks2 and I am creating and binding the sockets as such:
Code:
dac = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
bndt = bind(dac,(SOCKADDR*) &local,sizeof(local) );
I am using blocking send() and recv() inside of critical sections
and for the write command, the line to write the data appears as
Code:
EnterCriticalSection(&CriticalSection);
c = send(dac, (char*) &d,(int) sizeof(d),0);
LeaveCriticalSection(&CriticalSection);
The critical section is being used because pings are being used in a separate thread.