MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / open_serial_port

Method open_serial_port

src/utils/libftdi_serial.cpp:59–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59int LibFTDISerial::open_serial_port ()
60{
61 if (!lib_init)
62 {
63 // failed to init libftdi; at least check the port name
64 if (description.size () < 4)
65 {
66 return SerialExitCodes::PORT_NAME_ERROR;
67 }
68 if (description[0] == '/' || description[1] != ':')
69 {
70 return SerialExitCodes::PORT_NAME_ERROR;
71 }
72 return SerialExitCodes::OPEN_PORT_ERROR;
73 }
74 // https://www.intra2net.com/en/developer/libftdi/documentation/ftdi_8c.html#aae805b82251a61dae46b98345cd84d5c
75 last_result = ftdi_usb_open_string (&ftdi, description.c_str ());
76 if (last_result == 0)
77 {
78 port_open = true;
79 return (int)SerialExitCodes::OK;
80 }
81 log_error ("open_serial_port ()");
82 switch (last_result)
83 {
84 case -10:
85 return (int)SerialExitCodes::CLOSE_ERROR;
86 case -11:
87 return (int)SerialExitCodes::PORT_NAME_ERROR;
88 default:
89 return (int)SerialExitCodes::OPEN_PORT_ERROR;
90 }
91}
92
93bool LibFTDISerial::is_port_open ()
94{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected