Commit 9b6f43bf authored by Claes Sjofors's avatar Claes Sjofors

Modbus TCP module with both read and write

parent 7ef3456a
......@@ -71,12 +71,12 @@ static pwr_tStatus IoCardInit (
io_sCard *cp
)
{
io_sCardLocal *local;
io_sCardLocalMsg *local;
pwr_sClass_Modbus_Module *op;
int i;
op = (pwr_sClass_Modbus_Module *) cp->op;
local = (io_sCardLocal *) cp->Local;
local = ((io_sCardLocal *) cp->Local)->msg;
for (i = 0; i < IO_MAXCHAN; i++) {
local->scancount[i] = 0;
......@@ -98,12 +98,12 @@ static pwr_tStatus IoCardRead (
io_sCard *cp
)
{
io_sCardLocal *local;
io_sCardLocalMsg *local;
pwr_sClass_Modbus_Module *op;
pwr_sClass_Modbus_TCP_Slave *slave;
op = (pwr_sClass_Modbus_Module *) cp->op;
local = (io_sCardLocal *) cp->Local;
local = ((io_sCardLocal *) cp->Local)->msg;
slave = (pwr_sClass_Modbus_TCP_Slave *) rp->op;
if ( op->ScanInterval > 1) {
......@@ -118,7 +118,7 @@ static pwr_tStatus IoCardRead (
}
if (slave->Status == MB__NORMAL) {
io_bus_card_read(ctx, rp, cp, local->input_area, NULL, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
io_bus_card_read(ctx, rp, cp, slave->Inputs, NULL, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
}
// printf("Method Modbus_Module-IoCardRead\n");
return IO__SUCCESS;
......@@ -135,13 +135,13 @@ static pwr_tStatus IoCardWrite (
io_sCard *cp
)
{
io_sCardLocal *local;
io_sCardLocalMsg *local;
pwr_sClass_Modbus_Module *op;
pwr_sClass_Modbus_TCP_Slave *slave;
op = (pwr_sClass_Modbus_Module *) cp->op;
local = (io_sCardLocal *) cp->Local;
local = ((io_sCardLocal *) cp->Local)->msg;
slave = (pwr_sClass_Modbus_TCP_Slave *) rp->op;
if ( op->ScanInterval > 1) {
......@@ -159,7 +159,7 @@ static pwr_tStatus IoCardWrite (
}
if (slave->Status == MB__NORMAL) {
io_bus_card_write(ctx, cp, local->output_area, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
io_bus_card_write(ctx, cp, slave->Outputs, pwr_eByteOrderingEnum_BigEndian, pwr_eFloatRepEnum_FloatIntel);
}
// printf("Method Modbus_Module-IoCardWrite\n");
return IO__SUCCESS;
......
......@@ -112,6 +112,10 @@ typedef struct {
short int no_do;
int interval_cnt;
int has_read_method;
} io_sCardLocalMsg;
typedef struct {
io_sCardLocalMsg msg[2];
} io_sCardLocal;
typedef struct {
......
......@@ -2,6 +2,7 @@ MotionControl_USB
MotionControl_USBIO
Modbus_TCP_Slave
Modbus_Module
Modbus_ModuleReadWrite
Modbus_Master
Modbus_TCP_Server
Modbus_TCP_ServerModule
......
This diff is collapsed.
......@@ -142,7 +142,8 @@ static pwr_tStatus PostCreate( ldh_tSesContext Session,
if ( !repr_set) {
wb_cdef father_cdef = sp->cdef(Class);
if ( strcmp( father_cdef.name(), "Modbus_TCP_ServerModule") == 0 ||
strcmp( father_cdef.name(), "Modbus_Module") == 0) {
strcmp( father_cdef.name(), "Modbus_Module") == 0 ||
strcmp( father_cdef.name(), "Modbus_ModuleReadWrite") == 0) {
wb_attribute a = sp->attribute( Object, "RtBody", "Representation");
if ( !a) return a.sts();
......
......@@ -104,7 +104,8 @@ static pwr_tStatus PostCreate( ldh_tSesContext Session,
if ( !repr_set) {
wb_cdef father_cdef = sp->cdef(Class);
if ( strcmp( father_cdef.name(), "Modbus_TCP_ServerModule") == 0 ||
strcmp( father_cdef.name(), "Modbus_Module") == 0) {
strcmp( father_cdef.name(), "Modbus_Module") == 0 ||
strcmp( father_cdef.name(), "Modbus_ModuleReadWrite") == 0) {
wb_attribute a = sp->attribute( Object, "RtBody", "Representation");
if ( !a) return a.sts();
......
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