def find_vec_usb_footpedal(): all_hids = hid.find_all_hid_devices() for index, device in enumerate(all_hids): if (device.vendor_id == 0x05f3 and device.product_id == 0x00ff): print("Found VEC USB Footpedal") return all_hids[index] raise Exception("VEC USB Footpedal not found"); if __name__ == '__main__': try: footpedal = find_vec_usb_footpedal() # When starting the application, we default the instrument to the first # instrument in the global 'instruments' list current_instrument = instruments[selected_instrument_index] current_instrument.acquire() thread = Thread(target=background_worker, args=(current_instrument,)) thread.start() footpedal.open() footpedal.set_raw_data_handler(footpedal_handler) print("\nWaiting for data...\nPress any (system keyboard) key to stop...") while not kbhit() and footpedal.is_plugged(): #just keep the device opened to receive events sleep(0.5) finally: footpedal.close() virtualbench.release()
# Read the data by first querying how big the data needs to be, allocating the memory, and finally performing the read. analog_data, analog_data_stride, analog_t0, digital_data, digital_timestamps, digital_t0, trigger_timestamp, trigger_reason = mso.read_analog_digital_u64( ) # Finally, print some information about the data. print("Trigger Reason: %s" % trigger_reason) trigger_timestamp_seconds_since_1970, trigger_timestamp_fractional_seconds = virtualbench.convert_timestamp_to_values( trigger_timestamp) print("Trigger Timestamp: %s UTC\n\t%f fractional seconds" % (datetime.utcfromtimestamp(trigger_timestamp_seconds_since_1970), trigger_timestamp_fractional_seconds)) if (len(analog_data) != 0): print("Analog t0 is %f seconds before trigger" % get_timestamp_difference(trigger_timestamp, analog_t0)) if (len(digital_data) != 0): print("Digital t0 is %f seconds before trigger" % get_timestamp_difference(trigger_timestamp, digital_t0)) print_analog_data(analog_data, analog_data_stride, number_of_channels, sampling_mode, 10) print_digital_data(digital_data, digital_timestamps, 10) mso.release() except PyVirtualBenchException as e: print("Error/Warning %d occurred\n%s" % (e.status, e)) finally: virtualbench.release()