gpt4 book ai didi

c - USR-TCP232-T2 : Basic config and port config commands returns 0xBE 0x45 (Error)

转载 作者:行者123 更新时间:2023-11-30 16:27:28 24 4
gpt4 key购买 nike

这是我第一次使用USR-TCP232-T2模块(TTL-以太网转换器)。我的项目是通过串口(不是LAN口)对模块进行配置和Tx\Rx。当我发送基本参数配置命令或端口参数配置命令时,结果是0xBE 0x45(错误)。

说明:在初始化期间,我发送读取配置命令。模块返回137字节如下:

0x55 0xb                              - ducSequenceNum[2];
0x00 - ucCRC;
0x00 - ucVersion;
0x00 - UnknownParameter;
0x00 - ucFlags_1;
0x00 0x00 - usLocationURLPort[2];
0x50 0x00 - usHTTPServerPort[2];
0x00 - ucUserFlag;
0x07 0x00 0xa8 0xc0 - ulStaticIP[4];
0x01 0x00 0xa8 0xc0 - ulGatewayIP[4];
0x00 0xff 0xff 0xff - ulSubnetMask[4];
0x55, 0x53, 0x52, 0x2d, 0x54, 0x43, 0x50, 0x32
0x33, 0x32, 0x2d, 0x54, 0x32, 0x00 - ucModName[14];
0x00, 0x00 - ProtocolReserved[2];
0x61, 0x64, 0x6D, 0x69, 0x6E, 0x00 - username[6];
0x61, 0x64, 0x6D, 0x69, 0x6E, 0x00 - password[6];
0x00 - ucNetSendTime;
0x01, 0x00 - uiId[2];
0x80 - ucIdType;
0xd8, 0xb0, 0x4c, 0xf9, 0xb4, 0x8d - mac_addrs[6];
0xde, 0xde, 0x43, 0xd0 - DNS_Gateway_IP[4];
0x03, 0x00, 0x00, 0x00 - ucReserved_1[4];
0x00, 0xC2, 0x01, 0x00 - ulBaudRate[4];
0x08 - ucDataSize;
0x01 - ucParity;
0x01 - ucStopBits;
0x00 - ucFlowControl;
0x00, 0x00, 0x00, 0x00 - ulTelnetTimeout[4];
0x8C, 0x4E - usTelnetLocalPort[2];
0x2a, 0x20 - usTelnetRemotePort[2];
0x31, 0x39, 0x32, 0x2e, 0x31, 0x36,
0x38, 0x2e, 0x30, 0x2e, 0x32, 0x00,
0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - uiTelnetURL[30];
0xc9, 0x00, 0xa8, 0xc0 - ulTelnetIPAddr[4];
0x20 - ucFlags_2;
0x01 - ucWorkMode;
0x00 - HTPucFlags;
0x04 - tc_number;
0x10, 0x0e - uiPackLen[2];
0x00 - ucPackTime;
0x00 - ucTimeCount;
0x00, 0x00, 0x00, 0x00, 0x00 - ucReserved_2[5];
0xac 0x13 0x01 0x57 - Current_IP[4];
0xb1 - Version;

现在,当我发送基本参数配置命令时,与收到的配置相同:

0x55                                  - Start byte
0xBE - Basic parameters command code 0x00 - ucSequenceNum
0x00 - ucCRC
0x00, - ucVersion
0x00, - ucFlags - DHCP
0x00, 0x00, - usLocationURLPort[2]
0x50, 0x00, - usHTTPServerPort[2]
0x00, - ucUserFlag
0x07, 0x00, 0xA8, 0xC0, - ulStaticIP[4]
0x01, 0x00, 0xA8, 0xC0, - ulGatewayIP[4]
0x00, 0xFF, 0xFF, 0xFF, - ulSubnetMask[4]
0x55, 0x53, 0x52, 0x2d, 0x54,
0x43, 0x50, 0x32, 0x33, 0x32,
0x2d, 0x54, 0x32, 0x00, - ucModName[14]
0x00, 0x00, - ProtocolReserved[2]
0x61, 0x64, 0x6D, 0x69, 0x6E, 0x00, - username[6]
0x61, 0x64, 0x6D, 0x69, 0x6E, 0x00, - password[6]
0x00, - ucNetSendTime
0x01, 0x00, - uiId[2]
0x80, - ucIdType
0xd8, 0xb0, 0x4c, 0xf9, 0xb4, 0x8d, - mac_addrs[6]
0xde, 0xde, 0x43, 0xd0, - DNSGatewayIP[4]
0x03, 0x00, 0x00, 0x00 - ucReserved[4]
0xFF - CheckSum

USR-TCP232-T2 模块返回 0xBE 0x45,表示存在错误。

或者,当我发送端口参数配置命令时,与收到的配置相同:

0x55                                  - Start byte
0xBF - Port parameters command code
0x00, 0xC2, 0x01, 0x00, - ulBaudRate[4] - 115200 bps
0x08, - ucDataSize
0x01, - ucParity
0x01, - ucStopBits
0x00, - ucFlowControl
0x00, 0x00, 0x00, 0x00, - ulTelnetTimeout[4]
0x8C, 0x4E, - usTelnetLocalPort[2]
0x2a, 0x20, - usTelnetRemotePort[2]
0x31, 0x39, 0x32, 0x2e, 0x31, 0x36,
0x38, 0x2e, 0x30, 0x2e, 0x32, 0x00,
0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - uiTelnetURL[30]
0xc9, 0x00, 0xa8, 0xc0, - ulTelnetIPAddr[4]
0x20, - ucFlags
0x01, - ucWorkMode
0x00, - HTPucFlags
0x04, - tc_number
0x10, 0x0e, - uiPackLen[2]
0x00, - ucPackTime
0x00, - ucTimeCount
0x00, 0x00, 0x00, 0x00, 0x00 - ucReserved[5]
0xBD - CheckSum

USR-TCP232-T2 模块返回 0xBE 0x45,表示存在错误。

任何帮助将不胜感激。
提前致谢。

最佳答案

我发现问题了。发送命令的代码是:

u8 BasicSettingCom[] = {0x55, 0xBE, &basicParamsStruct, checkSum};
.
.
SendDataToClient((u8*)BasicSettingCom, Length);

因此发送的是 basicParamsStruct 的指针,而不是其内容。

现在发送命令的代码是:

const u8 BasicSettingCmd[] = {0x55, 0xBE};
.
.
SendDataToClient((u8*)BasicSettingCmd, cmdLen);
SendDataToClient((u8*)basicParamsStruct , dataLen);
SendByteToClient(checkSum);

而且效果很好。

关于c - USR-TCP232-T2 : Basic config and port config commands returns 0xBE 0x45 (Error),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52720227/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com