I am trying to use a pn532 board connected using an Adafruit FTDI Friend to my MacBook Pro. It pops up in /dev as "tty.usbserial-XXXXXXXX" (where the Xs are the serial number). I have tried things such as "tagtool.py --device=tty:usbserial-XXXXXXXX:pn532" but no success. I also tried that same connection string straight in my code.
Nfcpy doesn't seem to be detecting the PN532, but it detects my ACR122U over USB just fine. I have already confirmed its not the PN532 board, as libnfc on my Mac detects it, and it works fine on my Raspberry Pi.
My code to connect:
with nfc.ContactlessFrontend('tty:usbserial-XXXXXXXX:pn532') as clf:
tag = clf.connect(rdwr=rdwr_options)
if tag == False:
raise KeyboardInterrupt
With nfcpy 0.13.0 (and earlier versions) it was not possible to use serial ports on Mac OS X. The /dev/ naming scheme for OS-X has been added in nfcpy 0.13.1 and those ports are now automatically discovered or specifically selectable with the device path of nfc.ContactlessFrontend.open().
Related
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.
I have a device with USB interface which I can connect to both my Ubuntu 18.04 machine and my Windows 10 machine. On Windows 10 I have to install the CP210x driver and manually attach it to the device (otherwise Windows tries to find the device manufacturer's driver - it's a CP210x serial chip), and in Linux write the vendorID and productID to the cp210x driver to allow it to attach to ttyUSB0. This works fine.
The Windows driver is from SiliconLabs - the manufacturer of the UART-USB chip in the device.
So on Windows it is attached to COM5 and Linux to ttyUSB0 (Ubuntu, Raspbian)
Using Wireshark I can snoop the usb bus successfully on both operating systems.
The USB device sends data regularly over the USB bus and on Windows using Wireshark I can see this communication as "URB_INTERRUPT in" messages with the final few bytes actually containing the data I require.
On Linux it seems that the device connects but using Wireshark this time I can only see URB_BULK packets. Examining the endpoints using pyusb I see that there is no URB_Interrupt endpoint only the URB_Bulk.
Using the pyusb libraries on Linux it appears that the only endpoints available are URB_BULK.
Question mainly is how do I tell Linux to get the device to send via the Interrupt transfer mechanism as Windows seems to do. I don't see a method in pyusb's set_configuration to do this (as no Interrupt transfer endpoints appear) and haven't found anything in the manufacturer's specification.
Failing that, of course, I could snoop the configuration messages on Windows, but there has to be something I'm missing here?
Disregard this, the answer was simple in the end: Windows was reassigning the device address on the bus to a different device.
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 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 trying to run Vision Processing python code, through Raspberry Pi with the Microsoft Kinect camera.
I have perfectly working code running on Ubuntu but it fails to perform the same on the RPi.
I think I have all libraries installed on it...
I even tryied the following simple code:
import freenect
ir, data = freenect.sync_get_video(format=freenect.VIDEO_IR_8BIT)
print ir
It doesn't work, it gets stuck.
What could the reason?
Maybe the kinect and the raspberry Pi dont work together?
Note: When I try "freenect-glview" I get: "Number of devices found: 1"
Did you try using OpenNI SDK. I tried and it works with OpenNI Also do you have a powered USB hub as PI can't generate enough energy to power Kinect.
Kinect does not work on RPI due to an usb driver bug :
Linux Driver Issues
Shortly after the Raspberry Pi was released it was confirmed that there were a number of issues with the Linux USB driver for the
SMSC95xx chip.
These included problems with USB 1.x peripherals that use split transactions, a fixed number of channels (causing problems with
Kinect) and the way the ARM processor handles the SMSC95xx interrupts.
[2] [3] A large number of fixes were included in the
2012-08-19-Wheezy-raspbian Linux image.
source http://elinux.org/RPi_VerifiedPeripherals