西门子243模块通信

时间:2022-07-12 09:02:51

初始握手

const wstring g_InitFirstCmd = L"0300001611E00000000100C1024D57C2024D57C0010A";
const wstring g_InitCmd2 = L"0300001902F08032010000CCC100080000F0000001000103C0";
const wstring g_InitCmd3 = L"0300001F02F080320100000001000E00000401120A10020014000003000000";
const wstring g_InitCmd4 = L"0300001F02F080320100000002000E00000401120A10020001000005000020";


读:开始头 0300 + 报文长度(例如0016)  + 02F080320100000001000E00000401120A1002 + 读的长度(例如0001) + 标识码 + 开始地址

写要区分是boolean byte word dword 单独处理

T、C需要单独处理 

T:02F080320100000001000E00000401120A101F

C:02F080320100000001000E00000401120A101E


标识码

wstring g_TypeStrTagAddr[g_NumMaxAddrType] =
{
L"I",   L"IB",  L"IW", L"ID",
L"Q",   L"QB",  L"QW", L"QD",
L"V",   L"VB",  L"VW", L"VD",
L"M",   L"MB",  L"MW", L"MD",
L"SM",  L"SMB", L"SMW",L"SMD",


L"S",   L"SB",  L"SW", L"SD",
L"NULL",L"NULL",L"AIW",L"VF",
L"NULL",L"NULL",L"AQW",L"NULL",
L"T",   L"NULL",L"TPV",L"NULL",
L"C",   L"NULL",L"CPV",L"NULL"
};

wstring g_CodeStrRead[g_NumMaxAddrType] =  {
L"000081",L"000081",L"000081",L"000081",
L"000082",L"000082",L"000082",L"000082",
L"000184",L"000184",L"000184",L"000184",
L"000083",L"000083",L"000083",L"000083",
L"000005",L"000005",L"000005",L"000005",
L"000004",L"000004",L"000004",L"000004",
L"-1",    L"-1",    L"000006",L"000184",
L"-1",    L"-1",    L"000007",L"-1",
L"00001F",L"-1",    L"00001F",L"-1",
L"00001E",L"-1",    L"00001E",L"-1"
};