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.
Related
I want to capture traffic of a particular Android device using a Python script. I am doing the same thing for a laptop using "pyshark" that monitors the real-time traffic of laptop for a specific time and then creates a pcap file for it. I want to do the same thing for my Android device. I have tried Tcpdump, scapy and packetsniffer but nothing helped me in capturing the traffic of my Android device.
Ideally I want an analyzer (a python script) that should run in such a fashion that when it is turned on, it continuously monitors the traffic of my Android device. I will have to make something similar to a proxy server but i am stucked how to do it.
pyshark usage for my laptop
Does your program run with the necessary rights at all? Under Linux and Windows a program needs extended rights to open raw sockets, which are necessary for sniffing. Under Windows there must be some group policy XY setting (I don't know Windows), under Linux the program needs root rights.
I don't know about such a policy too. But in the scenario displayed in the picture attached, there is no need for socket programming. I am also okay with passive sniffing.
issue: unable to flash micropython to esp 32: open serial error, please try again. hope to connect internet and try again.
pretty new to micropython - want to flash micropython to esp 32 ( resp 8266) board.
cf this docs: https://maker.pro/esp8266/tutorial/using-micropython-on-an-esp8266-with-upycraft
getting this errors all the time.
open serial error, please try again.
hope to connect internet and try again.
current version only open py txt json ini file.
hope to connect internet and try again.
hope to connect internet and try again.
i run Win 7
the hardware:
a. Joy-IT-Node MCU ESP8266
.. and besides that i also tried it with the following
b. ESP32-T Development Board CP2102 with Espressif ESP-WROOM-32 IoT WLAN & BLE Modul
yes: i have installed the > CP210x_Universal_Windows_Driver.zip
by the way: i could try to do all that on a linux machine. - on a MX-Linux-Sytem
any idea;
many thanks for any and all help in advance.
As of my opinion, You don't necessarily depend on the uPyCraft IDE. So there are several other ways to develop scripts and uploading them to Your board.
Some days ago I was facing problems with Python on the NodeMcu as well. Since I didn't like the tutorials around the web, I've set up one on GitHub, covering the end-to-end process (required software, drivers, firmware images, developing, flashing, uploading, etc.): python2nodemcu.
It depends on Mac and the NodeMcu board, but some of the topics may apply to other operating systems and boards as well.
And I think it covers the most relevant parts of the whole process, using the easiest tools around the web. Please have a look at it, but all in all it goes like this (short version of the linked documentation above):
Install Python 3
Verify with python --version
Or python3 --version
Install the correct SiLabs driver to enable serial USB-to-UART communication
See here
Find the device file (representing the interface to the physical device)
Try it using ls -la /dev/tty.*
Download the recent MicroPython firmware
You need the right one for Your board
Install the two Python-based libraries EspTool and PySerial
Try to erase the flash of Your device
Run python3 esptool.py --port /dev/tty.{device-file} erase_flash
Try to flash the original image or the MicroPython firmware to the board
Run python3 esptool.py --port /dev/tty.{device-file} write_flash 0x00000 {micropython-image-or-original-firmware}.bin
Try to connect to the board via the REPL prompt
Run screen /dev/tty.{device-file} 115200
You maybe need to try different baud rates (depending on Your driver, cable, etc.)
Connect to the board using Ampy
For example, try to list the files on Your device executing python3 ampy/cli.py --port /dev/tty.{device-file} --baud 115200 ls
Again, try other baud rates
Anyway, I've noticed that You do not necessarily need to push the physical flash button on the device.
I have an RFID reader that works as a Keyboard, so, if I click on a Text Entry and put a card near the reader, it puts the content read on the text entry.
The latest RFID reader I was using works via serial connection, so I can open and close the connection to avoid fake positives, but with this new model, I can't do that, so I need to disable and enable the device without unplug it from the USB, just like if I do from the Windows Device Manager.
I have tried with pyusb but, in Windows, it doesn't display nothing, (I have tried the same on my RPi 3 and it works properly, but I don't know if I could disable the port).
By the way, I also tried with infi.devicemanager but this only list all peripherals connected and doesn't let me disable/enable it.
Is there any way to do this, like edit the registry, or acess it via cmd prompt.
Thanks!
There is command line tool for this called DevCon. You can disable devices using devcon-disable command. It's supported by Microsoft and since it's a command line tool you can use it programmatically. Here is an example.
I am really frustrated and have no idea where to search for an answer.
Currently I am working on a project to detect drowsiness with an ECG device (Zephyr Bioharness 3). The device works but I can't find it with windows (For example like this). I tried several things:
Find the device with my Smartphone -> works
Find the device with an Ubuntu on the same Laptop -> works
Connect directly on Win7 via Bluetooth with this Python Script: Gist -> connects and sends data
Find other Bluetooth devices with my Laptop on Win7 -> Bluetooth radio is dound
COM port for (virtual) serial connection to a bluetooth device (device manager)
What I am trying, is getting this script to work: ZephyrApp. Beside some compatibility problems with QT and serial (which I was able to fix), the programm hangs here protocol.py. I suspect the problems of not finding the device relates to the problems with the program. I know this is very special case, but hope anyone has an idea, how to fix this.
Regards,
paul
EDIT: Another PC with Win7 can't detect the device as well, it seems it is a Windows problem.
The device can't be detected with Win7, but I found a way to connect via bluetooth directly: https://gist.github.com/darkopetrovic/2127217
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.