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)
int offs;
short addr = ntohs( rmsg->addr);
short value = ntohs( rmsg->value);
unsigned short value = ntohs( rmsg->value);
unsigned char unit_id = rmsg->head.unit_id;
/* Check the address */
......@@ -447,13 +447,14 @@ static void *mb_receive( void *data)
}
mask = 1 << (addr % 8);
thread_MutexLock( &local->mutex);
if ( value)
*((char *)local_card->input_area + local_card->di_offset + offs) |= mask;
else
*((char *)local_card->input_area + local_card->di_offset + offs) &= ~mask;
thread_MutexUnlock( &local->mutex);
if ( value == 0xFF00 || value == 0) {
thread_MutexLock( &local->mutex);
if ( value == 0xFF00)
*((char *)local_card->input_area + local_card->di_offset + offs) |= mask;
else
*((char *)local_card->input_area + local_card->di_offset + offs) &= ~mask;
thread_MutexUnlock( &local->mutex);
}
msg.fc = fc;
msg.addr = rmsg->addr;
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