From 5b5ace8b2451f3279663679e6f57a9bca58e91b1 Mon Sep 17 00:00:00 2001 From: cw2k <3834079+cw2k@users.noreply.github.com> Date: Wed, 18 Jan 2023 02:05:39 +0100 Subject: [PATCH 1/2] Added const and coments for documentation --- scripts/issue_cmd.py | 49 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/scripts/issue_cmd.py b/scripts/issue_cmd.py index 54532f5e..38aa6532 100644 --- a/scripts/issue_cmd.py +++ b/scripts/issue_cmd.py @@ -22,11 +22,52 @@ # SOFTWARE. # import sys -import usb.core -dev = usb.core.find(idVendor=0x05ac, idProduct=0x4141) +import usb.core # sudo pip install pyusb libusb + +#$ lsusb +# ID 05ac:4141 Apple, Inc. pongoOS USB Device +dev = usb.core.find( idVendor=0x05ac, idProduct=0x4141 ) if dev is None: raise ValueError('Device not found') + dev.set_configuration() +# if you get 'usb.core.USBError: [Errno 5] Input/Output Error' +# create a file Pongo.rules in /etc/udev/rules.d/ with MODE="0666" + +bmRequest_Direction_HostToDevice = 0x00 +bmRequest_Direction_DeviceToHost = 0x80 + +bmRequest_Recipient_Interface = 0x01 +bmRequest_Type_Class = 0x20 + +#dev.ctrl_transfer( 0x21, 4, 0, 0, 0) +bmRequestType = \ + bmRequest_Direction_HostToDevice | \ + bmRequest_Type_Class | \ + bmRequest_Recipient_Interface + +dev.ctrl_transfer( + bmRequestType = bmRequestType, + bRequest = 3, + wValue = 0, + wIndex = 0, + data_or_wLength = sys.argv[1] + "\n", + timeout = None +) + + +#issue fetch stdout +bmRequestType = \ + bmRequest_Direction_DeviceToHost | \ + bmRequest_Type_Class | \ + bmRequest_Recipient_Interface -#dev.ctrl_transfer(0x21, 4, 0, 0, 0) -dev.ctrl_transfer(0x21, 3, 0, 0, sys.argv[1] + "\n") +print( "".join( chr (x) for x in dev.ctrl_transfer( + bmRequestType = bmRequestType, + bRequest = 1, + wValue = 0, + wIndex = 0, + data_or_wLength = 0x200 + ) + )) + From 06437efa7120ca07dea95a18d5083e742753d758 Mon Sep 17 00:00:00 2001 From: cw2k <3834079+cw2k@users.noreply.github.com> Date: Wed, 18 Jan 2023 02:14:04 +0100 Subject: [PATCH 2/2] Added comments and consts for documentation --- scripts/fetch_stdout.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/scripts/fetch_stdout.py b/scripts/fetch_stdout.py index 46e3c029..0f840906 100644 --- a/scripts/fetch_stdout.py +++ b/scripts/fetch_stdout.py @@ -23,11 +23,34 @@ # import sys -import usb.core -dev = usb.core.find(idVendor=0x05ac, idProduct=0x4141) +import usb.core # sudo pip install pyusb libusb + +#$ lsusb +# ID 05ac:4141 Apple, Inc. pongoOS USB Device +dev = usb.core.find( idVendor=0x05ac, idProduct=0x4141 ) if dev is None: raise ValueError('Device not found') dev.set_configuration() -#dev.ctrl_transfer(0x21, 4, 0, 0, 0) -print("".join(chr (x) for x in dev.ctrl_transfer(0xa1, 1, 0, 0, 512))) +dev.ctrl_transfer(0x21, 4, 0, 0, 0) + +bmRequest_Direction_HostToDevice = 0x00 +bmRequest_Direction_DeviceToHost = 0x80 + +bmRequest_Recipient_Interface = 0x01 +bmRequest_Type_Class = 0x20 + + +bmRequestType = \ + bmRequest_Direction_DeviceToHost | \ + bmRequest_Type_Class | \ + bmRequest_Recipient_Interface + +print( "".join( chr (x) for x in dev.ctrl_transfer( + bmRequestType = bmRequestType, + bRequest = 1, + wValue = 0, + wIndex = 0, + data_or_wLength = 0x200 + ) + ))