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).
Related
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.
I am programming a EV3 in microPython 2. I have another python 3 program running on a laptop and this program should send data to the EV3 wirelessly. Is it possible via bluetooth? If it isn't possible how should I do it?
I don't know the answer to this and I don't have an EV3 brick to try this with. As you haven't said what you have tried, I thought I would share some ideas for experiments to try.
I looked at the ev3-micropython documentation about Bluetooth and my search gave me this:
https://pybricks.github.io/ev3-micropython/messaging.html
This looks like the Bluetooth communication might be based on Bluetooth Serial Port Profile (SPP) so it might be worth seeing if SPP clients can communicate.
A first experiment might be to start a BluetoothMailboxServer on the EV3 and see if are you able to pair with it from your PC? (By the way, what OS are you running on your laptop?).
If you have Windows, do these instructions from this URL help:
https://www.instructables.com/id/Raspberry-Pi-Bluetooth-to-PuTTY-on-Windows-10/
On your Windows 10 Desktop/ Laptop first enable the Bluetooth
transceiver. Select Start, Settings, then Devices. At this point
resist the intuitive temptation to Add bluetooth or other device.
Instead, scroll down to 'Related settings', and select Devices and
printers. Find your Desktop/ Laptop under 'Devices', right click it,
then select Bluetooth settings from the pop up menu. This brings up
the 'Bluetooth settings dialogue:
Select the COM ports tab, then select Add... to bring up the 'Add COM
port' dialogue. Here we select the 'Outgoing' radio button, and then
click on Browse... This will yield the 'Select Bluetooth Device'
dialogue. All going well, you should see your Raspberry Pi listed as a
discovered device. Select the Raspberry Pi device listed, and click OK
twice. This should take you back to the COM ports tabbed dialogue, and
list a COM port that is now associated with the Windows 10/ Raspberry
Pi pairing. Take note of which COM port has been assigned.
On a Linux laptop, does creating a client this way work:
http://blog.kevindoran.co/bluetooth-programming-with-python-3/
Another alternative on Linux, is create a client this way:
https://bluedot.readthedocs.io/en/latest/btcommapi.html#bluetoothclient
If you have an Android phone, you could try pairing with the EV3 service from the phone and then trying to connect with this SPP app:
https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal
The other alternative is that the BluetoothMailboxServer might be using Bluetooth Low Energy (BLE). If that is the case, then you can find more information if you have a recent version of the Chrome browser on your laptop. Go to the URL chrome://bluetooth-internals/#devices and do a start scan. Does the EV3 device turn up?
About communication between EV3 and python code running on a laptop,
First we need to install the module python-ev3dev2 with the command:
pip install python-ev3dev2
About its usage, you can refer to ev3dev2.
Ensure that your ev3dev device is turned on and has a network connection to the host computer. Here Bluetooth works and there's a demo you can refer to: vscode-hello-python.
We are testing networking devices to which test interaction is done using serial ports. Python 2.7 with Windows is used to achieve this using the PySerial module of Python.
The scripts are run using Robot framework.
We observe that the Robot logs do not contain the serial device interaction dialogues.
We tried checking on Robot framework forums and it is unlikely that such support exists at Robot framework level.
We need to implement this in Python.
How can the following be achieved:
I) Basic requirement: All script interaction with the (multiple) test devices on serial port needs to be captured into a log file
II) Advanced requirement: while the script is not actively interacting with the test device there has to be continuous background monitoring of the device under test over serial ports for any errors/crashes
Thanks!
I may be incorrect but perhaps you want to capture data sent/received between computer and device through serial port. If this is true then serial port sniffer will be required. Linux and mac os x does not support sniffing however you may use sniffing for windows.
I am trying to communicate with a Bluetooth COM port, via Python on a Windows 7 machine. Since this Computer has no built-in Bluetooth, I use a USB stick which works with BlueSoleil (https://en.wikipedia.org/wiki/BlueSoleil).
My problem seems to be, that BlueSoleil, after a successfull pairing to a COM port, Python cannot open it (access denied). When I define a serial port with PySerial and try to write to it without opening it explicitly, I have no success and a few minutes later the computer crashes with a bluescreen.
When using a terminal (Kitty), I can read and write from and to the port.
My suspicion is, that PySerial tries to 'block' the port, which conflicts with BlueSoleil, but I am not sure.
Any Ideas?
Alright, it seems, that the Problem is bad drivers of the no-name Bluetooth Dongle under Win 7.
I am now using a Raspberry Pi with Raspbian and after installing the needed Packages and loading the needed modules, I have no Problems to connect my Bluetooth device to a serial port.
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.