-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c310274
commit b1b88cd
Showing
5 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import logging | ||
import serial | ||
from usb_keywords import find_port_name_from_USB_ids | ||
from robot.libraries.BuiltIn import BuiltIn | ||
|
||
|
||
def a_serial_connection_to_the_device_is_opened(): | ||
|
||
port_name = find_port_name_from_USB_ids(0x16c0, 0x05E1) | ||
logging.info(f"Try to open port: {port_name}") | ||
|
||
ser = serial.Serial(port_name, 9600, timeout=1) | ||
ser.open() | ||
|
||
BuiltIn().set_global_variable('${SERIAL}', ser) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,33 @@ | ||
import serial | ||
import logging | ||
import serial.tools.list_ports | ||
|
||
from robot.libraries.BuiltIn import BuiltIn | ||
|
||
|
||
############################################################################### | ||
|
||
def I_list_all_the_USB_devices(): | ||
pass | ||
devices_object = [] | ||
devices = serial.tools.list_ports.comports() | ||
for device in devices: | ||
devices_object.append({ | ||
"port_name": device.device, | ||
"pid": device.pid, | ||
"vid": device.vid, | ||
"serial_number": device.serial_number | ||
}) | ||
logging.debug("All devices: ", devices_object) | ||
BuiltIn().set_global_variable('${ALL_DEVICES}', devices_object) | ||
|
||
############################################################################### | ||
|
||
def find_port_name_from_USB_ids(vid, pid): | ||
devices = serial.tools.list_ports.comports() | ||
for device in devices: | ||
if device.vid == vid and device.pid == pid: | ||
return device.device | ||
return None | ||
|
||
############################################################################### | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# pip install -r requirements.txt | ||
pyserial==3.4 | ||
|