Commit 826ee2c5 authored by Claes Sjofors's avatar Claes Sjofors

IO Arduino write response wasn't handled

parent 112be641
...@@ -94,6 +94,8 @@ typedef struct { ...@@ -94,6 +94,8 @@ typedef struct {
int DiPollId; int DiPollId;
int DiPendingPoll; int DiPendingPoll;
ard_eMsgType PendingMsgType; ard_eMsgType PendingMsgType;
int ReceiveWriteRespons;
int WriteId;
int AiIntervalCnt; int AiIntervalCnt;
int AoIntervalCnt; int AoIntervalCnt;
int Reconnect; int Reconnect;
...@@ -612,6 +614,21 @@ static pwr_tStatus IoCardRead( io_tCtx ctx, ...@@ -612,6 +614,21 @@ static pwr_tStatus IoCardRead( io_tCtx ctx,
if ( local->Reconnect) if ( local->Reconnect)
return IO__SUCCESS; return IO__SUCCESS;
if ( local->ReceiveWriteRespons) {
// Receive response status from last write
ard_sMsg rmsg;
sts = receive( local->fd, local->WriteId, &rmsg, 1, op->Timeout, op);
if ( EVEN(sts))
op->ErrorCount++;
else {
op->Status = rmsg.data[0];
if ( EVEN(op->Status))
op->ErrorCount++;
}
local->ReceiveWriteRespons = 0;
}
if ( local->AiSize) { if ( local->AiSize) {
skip_ai = 0; skip_ai = 0;
...@@ -877,6 +894,10 @@ static pwr_tStatus IoCardWrite( io_tCtx ctx, ...@@ -877,6 +894,10 @@ static pwr_tStatus IoCardWrite( io_tCtx ctx,
add_checksum( &msg); add_checksum( &msg);
sts = write( local->fd, &msg, msg.size); sts = write( local->fd, &msg, msg.size);
if ( sts > 0) {
local->ReceiveWriteRespons = 1;
local->WriteId = msg.id;
}
} }
else if ( local->AoSize && !local->DoSize) { else if ( local->AoSize && !local->DoSize) {
...@@ -944,6 +965,10 @@ static pwr_tStatus IoCardWrite( io_tCtx ctx, ...@@ -944,6 +965,10 @@ static pwr_tStatus IoCardWrite( io_tCtx ctx,
add_checksum( &msg); add_checksum( &msg);
sts = write( local->fd, &msg, msg.size); sts = write( local->fd, &msg, msg.size);
if ( sts > 0) {
local->ReceiveWriteRespons = 1;
local->WriteId = msg.id;
}
} }
} }
else if ( local->DoSize && !skip_ao) { else if ( local->DoSize && !skip_ao) {
...@@ -1035,6 +1060,10 @@ static pwr_tStatus IoCardWrite( io_tCtx ctx, ...@@ -1035,6 +1060,10 @@ static pwr_tStatus IoCardWrite( io_tCtx ctx,
add_checksum( &msg); add_checksum( &msg);
sts = write( local->fd, &msg, msg.size); sts = write( local->fd, &msg, msg.size);
if ( sts > 0) {
local->ReceiveWriteRespons = 1;
local->WriteId = msg.id;
}
} }
if ( sts < 0) { if ( sts < 0) {
......
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