Commit ae30438d authored by Claes Sjofors's avatar Claes Sjofors

Modbus TCP server, correction for WriteSingleCoil. If value is not 0 or...

Modbus TCP server, correction for WriteSingleCoil. If value is not 0 or 0x00FF, no value should be set
parent a8096801
...@@ -418,7 +418,7 @@ static void *mb_receive( void *data) ...@@ -418,7 +418,7 @@ static void *mb_receive( void *data)
int offs; int offs;
short addr = ntohs( rmsg->addr); short addr = ntohs( rmsg->addr);
short value = ntohs( rmsg->value); unsigned short value = ntohs( rmsg->value);
unsigned char unit_id = rmsg->head.unit_id; unsigned char unit_id = rmsg->head.unit_id;
/* Check the address */ /* Check the address */
...@@ -447,13 +447,14 @@ static void *mb_receive( void *data) ...@@ -447,13 +447,14 @@ static void *mb_receive( void *data)
} }
mask = 1 << (addr % 8); mask = 1 << (addr % 8);
if ( value == 0xFF00 || value == 0) {
thread_MutexLock( &local->mutex); thread_MutexLock( &local->mutex);
if ( value) if ( value == 0xFF00)
*((char *)local_card->input_area + local_card->di_offset + offs) |= mask; *((char *)local_card->input_area + local_card->di_offset + offs) |= mask;
else else
*((char *)local_card->input_area + local_card->di_offset + offs) &= ~mask; *((char *)local_card->input_area + local_card->di_offset + offs) &= ~mask;
thread_MutexUnlock( &local->mutex); thread_MutexUnlock( &local->mutex);
}
msg.fc = fc; msg.fc = fc;
msg.addr = rmsg->addr; msg.addr = rmsg->addr;
msg.value = rmsg->value; msg.value = rmsg->value;
......
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