facedancer.devices.ftdi module

Emulation of an FTDI USB-to-serial converter.

class facedancer.devices.ftdi.FTDIDevice(*, name: str = 'generic device', device_class: int = 0, device_subclass: int = 0, protocol_revision_number: int = 0, max_packet_size_ep0: int = 64, vendor_id: int = 1027, product_id: int = 24577, manufacturer_string: ~facedancer.descriptor.StringRef = <factory>, product_string: ~facedancer.descriptor.StringRef = <factory>, serial_number_string: ~facedancer.descriptor.StringRef = <factory>, supported_languages: tuple = (LanguageIDs.ENGLISH_US,), device_revision: int = 1536, usb_spec_version: int = 512, device_speed: DeviceSpeed = None, requestable_descriptors: Dict[tuple[int, int], Union[bytes, callable]] = <factory>, configurations: Dict[int, USBConfiguration] = <factory>, backend: FacedancerUSBApp = None, serial_number: str = 'FT123450')[source]

Bases: USBDevice

Class implementing an emulated FTDI device.

device_revision: int = 1536
eeprom_data = [1088, 772, 352, 6, 32813, 2048, 2, 6162, 10784, 18450, 0, 0, 4611, 28160, 28416, 29696, 11520, 17920, 21504, 17408, 18688, 7683, 17920, 21504, 17408, 18688, 8192, 25856, 27904, 29952, 27648, 24832, 29696, 26880, 28416, 28160, 4611, 17920, 21504, 12544, 12800, 13056, 13312, 13568, 12288, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27495]
handle_data_received(endpoint, data)[source]

Called back whenever data is received.

handle_get_latency_timer_request = <ControlRequestHandler wrapping FTDIDevice.handle_get_latency_timer_request at 0x7f80a8183050
handle_get_modem_status_request = <ControlRequestHandler wrapping FTDIDevice.handle_get_modem_status_request at 0x7f80a8183830
handle_modem_ctrl_request = <ControlRequestHandler wrapping FTDIDevice.handle_modem_ctrl_request at 0x7f80a8180080
handle_read_eeprom_request = <ControlRequestHandler wrapping FTDIDevice.handle_read_eeprom_request at 0x7f80a8183a70
handle_reset_request = <ControlRequestHandler wrapping FTDIDevice.handle_reset_request at 0x7f80a80f9490
handle_serial_data_received(data)[source]

Callback executed when serial data is received.

Subclasses should override this to capture data from the host.

handle_set_baud_rate_request = <ControlRequestHandler wrapping FTDIDevice.handle_set_baud_rate_request at 0x7f80a8181070
handle_set_data_request = <ControlRequestHandler wrapping FTDIDevice.handle_set_data_request at 0x7f80a8180590
handle_set_error_char_request = <ControlRequestHandler wrapping FTDIDevice.handle_set_error_char_request at 0x7f80a81825a0
handle_set_event_char_request = <ControlRequestHandler wrapping FTDIDevice.handle_set_event_char_request at 0x7f80a8181460
handle_set_flow_ctrl_request = <ControlRequestHandler wrapping FTDIDevice.handle_set_flow_ctrl_request at 0x7f80a8180da0
handle_set_latency_timer_request = <ControlRequestHandler wrapping FTDIDevice.handle_set_latency_timer_request at 0x7f80a8182a20
manufacturer_string: StringRef
product_id: int = 24577
product_string: StringRef
reset_ftdi()[source]

Resets the FTDI driver back to its original state.

serial_number: str = 'FT123450'
serial_number_string: StringRef
transmit(data: str | bytes, *, blocking: bool = False, adjust_endings: bool = True)[source]

Transmits a block of data over the provided FTDI link to the host.

Parameters:
  • data – The data to be sent.

  • blocking – If true, this method will wait for completion before returning.

  • adjust_endings – If true, line endings will be adjusted before sending.

vendor_id: int = 1027
async wait_for_host()[source]

Waits until the host connects by waiting for DTR assertion.

class facedancer.devices.ftdi.FTDIFlowControl(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntFlag

Constants describing how FTDI flow control works.

DTR_DSR = 2
NO_FLOW_CONTROL = 0
RTS_CTS = 1
XON_XOFF = 4