+int _ReadBit(int BitNum, uint8_t *Value)
+{
+ errno = 0;
+ if( !gCoke_Modbus && Coke_int_ConnectToPLC() )
+ return -1;
+ if( modbus_read_bits( gCoke_Modbus, BitNum, 1, Value) >= 0 )
+ return 0;
+ if( Coke_int_ConnectToPLC() )
+ return -1;
+ if( modbus_read_bits( gCoke_Modbus, BitNum, 1, Value) >= 0 )
+ return 0;
+ return -1;
+}
+
+int _WriteBit(int BitNum, uint8_t Value)
+{
+ errno = 0;
+ if( !gCoke_Modbus && Coke_int_ConnectToPLC() )
+ return -1;
+ if( modbus_write_bit( gCoke_Modbus, BitNum, Value != 0 ) >= 0 )
+ return 0;
+ // Error case
+ if( Coke_int_ConnectToPLC() )
+ return -1;
+ if( modbus_write_bit( gCoke_Modbus, BitNum, Value != 0 ) >= 0 )
+ return 0;
+ return -1;
+}
+