Modbus Master 写单个线圈

Posts: 1
Joined: Thu Jan 14, 2021 6:20 am

Modbus Master 写单个线圈

Postby kayson » Thu Jan 14, 2021 6:26 am

基于modbus/serial/mb master
  1. {CID_RELAY_P1, STR("RelayP1"), STR("on/off"), MB_DEVICE_ADDR1, MB_PARAM_COIL,    -1, 1,
  2.                 COIL_OFFSET(coils_port0), PARAM_TYPE_U16, 2, OPTS(BIT0, 0, 0), PAR_PERMS_READ_WRITE}


Posts: 83
Joined: Fri Feb 01, 2019 4:02 pm

Re: Modbus Master 写单个线圈

Postby ESP_alisitsyn » Thu Jan 28, 2021 1:27 pm

Hi @kayson ,

The Modbus command 0x0F (Writes Multiple Coils) can be used to set one or more coils. Usually it is enough to support only this command to write coils. The current stack implementation has this constraint in the design. If your device supports only command 0x05 (Force Single Coil) the stack should be updated to add this support. If you really need this I can provide instructions or patch to fix this for your project. Again, this is not issue but design decision.
Another way to implement it is to use
eMBMasterReqWriteCoil( UCHAR ucSndAddr, USHORT usCoilAddr, USHORT usCoilData, LONG lTimeOut )
or change implementation of
esp_err_t mbc_serial_master_send_request(mb_param_request_t* request, void* data_ptr)
function to use the above function when we set just one coil.

Who is online

Users browsing this forum: No registered users and 6 guests