Ok, I have tried a slightly different approach. This way it says that I am receiving 1 byte from the port. But I am having trouble with casting the receive buffer as a COMMAND_PACKET. Error: Conversion to non-scalar type requested. Highlighted in Yellow
Here is my latest attempt
Code:
int receive_packet(COMMAND_PACKET *packet)
{
DWORD dwRetVal;
DWORD buflen;
LPVOID ReplyBuffer;
unsigned char buf[20];
buflen = sizeof(incoming_command);
ReplyBuffer = (VOID*) malloc(buflen);
if(ReplyBuffer == NULL) {
printf("ReplyBuffer: Error");
return 1;
}
memset(ReplyBuffer, 0, buflen);
incoming_command = (COMMAND_PACKET *)ReplyBuffer;
dwRetVal = ReadFile(handle,
buf,
1,
&buflen,
NULL);
if(dwRetVal != 0) {
printf("Received %ld bytes\n", dwRetVal);
printf("Received Packet: %s\n", buf[1]);
}
}
in the code incoming_command is defined as a COMMAND_PACKET
Do you see why I want to cast ReplyBuffer as a COMMAND_PACKET, so that I can read it?
How might this be acomplished?