Add modbus_send_raw_msg api function
Add a modbus_send_raw_msg api function,for the reason that sending a raw message with serial port is requested. Sometimes we will send message use serial port to the device using modbus and not using modbus protocol,in this case we can use this function.
if you need this sort of thing, just get the fd from the context and call write() yourself. there's no reason for this sort of hackjob inside the library itself.
I agree with @karlp. There is even a function to get the file-descriptor from the modbus-context: modbus_get_socket() (https://github.com/stephane/libmodbus/blob/master/src/modbus.h#L183)
The way above will not work, when using rs485. I must hack deep and get more private variables and functions for the flow control (RTS). Codes as this,
modbus_rtu_t *ctx_rtu = ctx->backend_data;
if (ctx_rtu->rts != MODBUS_RTU_RTS_NONE) {
ssize_t size;
if (ctx->debug) {
fprintf(stderr, "Sending request using RTS signal\n");
}
ctx_rtu->set_rts(ctx, ctx_rtu->rts == MODBUS_RTU_RTS_UP);
usleep(ctx_rtu->rts_delay);
size = write(ctx->s, req, req_length);
usleep(ctx_rtu->onebyte_time * req_length + ctx_rtu->rts_delay);
ctx_rtu->set_rts(ctx, ctx_rtu->rts != MODBUS_RTU_RTS_UP);
return size;
}