def node2_read_variable(ser, variable_id): can_cmd.can_transmit(ser, msg_id=variable_id, msg_len=0, msg_data=[]) try: return comms.read_signed_32_from_node2(ser) except comms.ReadException: print("Trying to resync!") basic_cmd.synchronize(ser)
def test_synchronize_2(ser): assert basic_cmd.synchronize(ser) == 0
def ser(): ser = comms.open_serial_connection('COM3') basic_cmd.synchronize(ser) yield ser ser.close()
assert init_success == 1 mcp2515_cmd.write_can_rx_flag(ser, 1) time.sleep(3) encoder_value = motor_read_encoder(ser) print("Encoder_value", motor_read_encoder(ser)) assert encoder_value > 3000 assert encoder_value < 4000 if __name__ == '__main__': ser = comms.open_serial_connection('COM3') basic_cmd.synchronize(ser) setpoint = 3000 start_time = time.time() while True: print(read_all_regulator_variables(ser)) time.sleep(1) #if ((time.time() - start_time) > 10): # start_time = time.time()# # if setpoint == 5000: # setpoint = 3000 # else: # setpoint = 5000