Hi all,
I want to import binary data via serial port (RS-232) directly in a structure (user-defined datatype) and, in a second time, put them in a DB.
I know that I must use MSCOMM ocx but I don't know how I can deserialize binary data directly in a user-defined data type.
Try to speak better. In my situation:
1)
PC sends an update request to the
MACHINE
2) the
MACHINE sends to the PC many packets with this structure:
HEADER + Packet + FOOTER
3)
PC put this data in a DB table and send an
ACK to the
MACHINE.
Now, the header has this structure (not VB6, it is only descriptive):
struct theader
{
unsigned char id[8];
unsigned int packet_type;
unsigned int n_bytes;
}header;
The footer:
struct tfooter
{
unsigned char id[4];
unsigned int packet_type;
unsigned int last_session;
unsigned int cks;
}footer;
Packet:
struct lot
{
char lot_element[16];
char lot[8];
unsigned short percent;
unsigned short lot_number;
unsigned int quantity;
}
In the
onComm() event of the
MSCOMM.ocx control I receive the data, but I can't find any information on how to put this data directly in the
lot type. i.e. how to deserialize binary data.
Anyone can help me? :confused:
Thanks!
Eric R.