There are some libraries such as CircuitPython that allow programmers to interact with Arduinos but can one control PC hardware such as the keyboard, usb ports, mouse etc using python?
I have explored various websites but they all focus on controlling Arduinos and Pyboards. I have also tried using the Linux Kernel API (kernel_ffi) but it seems impossible to make a cross-platform script with it.
Related
I need to create an arcade cabinet with a clone of an old arcade videogame. A Raspberry PI3 must be used for the:
Running the videogame
External LEDs Control via GPIO
A USB joystick must be used for the control of the main character. I must read the buttons and axis of the joystick from the game. The game is written on java and uses library processing-core.jar (library of the programming language processing). But I cannot find any library to read the button states from Java that runs on Raspberry Pi OS.
I used GameControlPlus - library for processing, but it doesn't work on this processor architecture with this operating system: It can not find right native methods. I tried to emulate my keyboard and mouse via a USB controller. But I need to launch this software and select the configuration file by every launch of the raspberry pi. I founded, that the controller info lays in the dev/controls and the USB controller signals can be read from this directory using evdev, but it uses Python. But I use Java and don't know any another programming languages.
I have set up a pyperclip script in python 3.6.3 which allows me to control my computer with keyboard requests. Is it possible to send these requests to another computer with python installed via USB, so that these actions are now carried out on the second computer?
It is possible to link two computers via USB and to communicate via USB using python. You have to use a special USB cable (https://www.quora.com/Is-it-possible-to-connect-2-computers-with-a-USB-cable), and you can use a library like pyusb to achieve that.
However it might be complicated as the USB protocol works as master/slave and a computer is not designed to be a slave on an USB bus (it is the master). A simpler solution if you computers are connected on a network would be to use sockets (https://docs.python.org/3/library/socket.html), or even a python HTTP server/client application (https://docs.python.org/3/library/http.server.html).
Short version: How do I monitor a USB port's input?
Long version: I wanted to use a console controller for my pc games, but couldn't find a freeware method of doing so that I liked. So I decided to make one myself, as much as a learning exercise as anything else, but I'm not sure how to monitor input on a USB port. I assume that if I can monitor one, it won't be hard to experimentally determine what each input is (A button = 00011 etc) on the keyboard, mouse and controller and then just convince the computer that the controller is a keyboard/mouse by switching whatever is inputted by it to what would have been inputted by one of the other devices.
I tried Google, but no luck. Same with this site. I know some C, C++ and Python but I wouldn't call myself a power user of any of them, part of the reason I'm doing this really. Currently using Windows Vista and Windows 10. Any help getting started would be appreciated.
Try pyusb and you will find examples on how to communicate with USB devices. It seems that the current repository is at GitHub: https://github.com/walac/pyusb
I have a PyUSB+PyQt script working on windows interfacing with a USB printer. I want to respond to printer connect/disconnect events.
I am unsure on how to write the event loop to keep monitoring the USB port. I will also have some processing going on in my main program, so should this be running in a separate thread.
Could someone help with the best practice to build this kind of a PyUSB functionality ?
I am testing a piece of hardware which hosts an ftp server. I connect to the server in order to configure the hardware in question.
My test environment is written in Python 3.
To start the ftp server, I need to launch a special proprietary terminal application on my pc. I must use this software as far as I know and I have no help files for it. I do however know how to use it to launch the ftp server and that's all I need it for.
When I start this app, I go to the menu and open a dialog where I select the com port/speed the hardware is connected to. I then enter the command to launch the ftp server in a console like window within the application. I am then prompted for the admin code for the hardware, which I enter. When I'm finished configuring the device, I issue a command to restart the hardware's software.
In order for me to fully automate my tests, I need to remove the manual starting of this ftp server for each test.
As far as I know, I have two options:
Windows GUI automation
Save the stream of data sent on the com port when using this application.
I've tried to find an GUI automater but pywinauto isn't supporting Python 3. Any other options here which I should look at?
Any suggestions on how I can monitor the com port in question and save the traffic on it?
Thanks,
Barry
Have you looked at pySerial? It's been a few years since I've used it but it was quite good at handling RS-232 communications and it looks like it's compatible with Python 3.x.
Sikuli might provide the kind of GUI automation you need.
I was also able to solve this using WScript, but pySerial was the preferred solution.