Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added comments and consts for documentation #153

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions scripts/fetch_stdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
))
49 changes: 45 additions & 4 deletions scripts/issue_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
))