Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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];        //"MAV H"
unsigned int packet_type;   //there is many type of packet ()
unsigned int n_bytes;
}header;


The footer:

C#
struct tfooter
{
unsigned char id[4];        //"MAV F"
unsigned int packet_type;
unsigned int last_session;//1 if the last, 0 otherwise 
unsigned int cks;
}footer;


Packet:

C#
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.


Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900