Reputation: 126
I'm trying to send a CAN message using WiFi.
The message is composed of a 2 byte ID (WORD) and a 8 byte data field (QWORD).
I have to write the packet to the WiFi chip using UART so I want to convert the WORD and QWORD to a string and then use putsUART to send it.
How can I convert those variables to a string?
Struct of the WiFi packet:
typedef struct {
WORD id;
QWORD data;
} WiFiTXPacket;
Upvotes: 0
Views: 3111
Reputation: 126
char *package = (char *)&wifiPackage;
putsUART(package, sizeof (WiFiTXPacket));
Depend on Gossamer's answer. I think it could be like this. if use memcpy function. and calculate with strlen(packeage). if there any zero value. may cause problem happened!
Upvotes: 1
Reputation: 309
Maybe something like this:
char package[10];
memcpy (&package, &wifiPackage, sizeof (WiFiTXPacket));
putsUART(package, strlen(package)); // i dont know how this function looks like, but for example ...
Upvotes: 2