1、common.h
//通信传输的IP地址
typedef struct
{
char serverIp[16];
int iPort;
}CONNINFO; //定义连接信息数据结构
//定义发送数据的结构体
typedef struct
{
double R_Box_Num;//每行箱数Row_Box_Num
double S_Layer_Num;//堆垛层数Stacking_Layer_Num
double S_Row_Num;//堆垛行数Stacking_Row_Num
double C_Length_Left;//集装箱剩余长度Container_Length_Left
}POSDATA;
2、mobus.h
//通信函数
/*
创建扩展MEMOBUS协议指令
*/
//TCP通信头文件
#include <stdio.h>
#include <iostream>
#include <string>
#include <Winsock2.h> //windows socket的头文件
#include <Winioctl.h>
#include <math.h>
#include <winsock2.h>
#include "common.h"
#pragma comment (lib, "ws2_32.lib") //加载 ws2_32.dll
#define DATA_SIZE 4096
#define TCP_IP_ADDR "192.168.1.1"
#define TCP_PORT 1029
ex