Commit d6855af6 authored by Claes Sjofors's avatar Claes Sjofors

Modbus TCP, function code WriteSingleRegister added

parent a7b09b7c
......@@ -87,8 +87,6 @@ static pwr_tStatus IoCardRead (
pwr_sClass_Modbus_TCP_ServerModule *op;
pwr_sClass_Modbus_TCP_Server *server;
printf( "Module: Read method\n");
op = (pwr_sClass_Modbus_TCP_ServerModule *) cp->op;
local = (io_sServerModuleLocal *) cp->Local;
server = (pwr_sClass_Modbus_TCP_Server *) rp->op;
......@@ -124,8 +122,6 @@ static pwr_tStatus IoCardWrite (
pwr_sClass_Modbus_TCP_ServerModule *op;
pwr_sClass_Modbus_TCP_Server *server;
printf( "Module: Write method\n");
op = (pwr_sClass_Modbus_TCP_ServerModule *) cp->op;
local = (io_sServerModuleLocal *) cp->Local;
server = (pwr_sClass_Modbus_TCP_Server *) rp->op;
......
......@@ -303,6 +303,7 @@ pwr_tStatus mb_recv_data(io_sRackLocal *local,
case pwr_eModbus_FCEnum_WriteMultipleCoils:
case pwr_eModbus_FCEnum_WriteMultipleRegisters:
case pwr_eModbus_FCEnum_WriteSingleRegister:
// Nothing good to do here
break;
}
......@@ -513,6 +514,33 @@ pwr_tStatus mb_send_data(io_sRackLocal *local,
wrr.bc = local_card->output_size;
memcpy(wrr.reg, local_card->output_area, local_card->output_size);
sts = send(local->s, &wrr, ntohs(wrr.head.length) + 6, MSG_DONTWAIT);
if (sts < 0) {
sp->Status = MB__CONNDOWN;
close(local->s);
errh_Error( "Connection down to modbus slave, %s", rp->Name);
return IO__SUCCESS;
}
sp->TX_packets++;
local->expected_msgs++;
break;
}
case pwr_eModbus_FCEnum_WriteSingleRegister: {
write_single_req wrr;
mp->SendOp = FALSE;
local->trans_id++;
local_card->trans_id = local->trans_id;
wrr.head.trans_id = htons(local->trans_id);
wrr.head.proto_id = 0;
wrr.head.length = htons(sizeof(wrr) - 6);
wrr.head.unit_id = mp->UnitId;
wrr.fc = mp->FunctionCode;
wrr.addr = htons(mp->Address);
memcpy(&wrr.value, local_card->output_area, sizeof(wrr.value));
sts = send(local->s, &wrr, ntohs(wrr.head.length) + 6, MSG_DONTWAIT);
if (sts < 0) {
sp->Status = MB__CONNDOWN;
......
......@@ -637,7 +637,6 @@ Volume OtherIO $ClassVolume 0.0.250.10
Object Port $Attribute 19 04-DEC-2009 17:22:45.73
Body SysBody 04-DEC-2009 17:23:01.72
Attr PgmName = "Port"
Attr Flags = 16777216
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
......@@ -1297,7 +1296,9 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndObject
EndObject
Object Template Modbus_TCP_Server 2149285888 01-JAN-1970 01:00:00.00
Body RtBody 01-JAN-1970 01:00:00.00
Body RtBody 03-MAR-2010 16:51:13.57
Attr Process = 1
Attr ErrorLimit = 50
EndBody
EndObject
EndObject
......@@ -1432,7 +1433,8 @@ Volume OtherIO $ClassVolume 0.0.250.10
EndObject
EndObject
Object Template Modbus_TCP_ServerModule 2149548032 01-JAN-1970 01:00:00.00
Body RtBody 01-JAN-1970 01:00:00.00
Body RtBody 03-MAR-2010 16:49:58.18
Attr Process = 1
EndBody
EndObject
EndObject
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment