USB-to-serial driver for Linux - python

I have a USB device that I need to control in Linux using Python and serial commands, it works with ASCII commands.
In Windows it works fine after I install the vendor driver and in Device Manager I see it as a COM3 port and I communicate using pyserial or pyvisa modules.
In Linux I see it as /dev/ttyUSB1 but I cannot communicate with it using pyserial or pyvisa. The problem is that the vendor doesn't provide Linux drivers.
How am I able to get the device behave as a serial port in Linux?

try python -m serial.tools.miniterm /dev/ttyUSB1 and read the issue on https://github.com/pyserial/pyserial/issues/67 especially the version of pyserial
if this issue is related to yours possibly this also works :
Managed to bypass this issue by passing dsrdtr=True and rtscts=True to
serial.Serial() ... as described here
your device is based on an FTDI chip, the inbuilt linux kernel module for this is ftdi_sio and usb_serial see http://www.ftdichip.com/Support/Documents/AppNotes/AN_220_FTDI_Drivers_Installation_Guide_for_Linux.pdf

Related

Send command to MacBook Terminal from Pycharm installed on virtual Windows

Background:
Through VMWare Fusion installed on my MacBook, I have Windows installed virtually in the VMWare Fusion environment. On the Windows, I have Pycharm IDE through which I run automated python program to control bench instruments from Keysight and Techroniks. No issues.
PS- The instrument drivers are available only for Windows, thats the reason I am using Windows virtually on MacBook
Question:
From Pycharm (installed on virtual Windows), I would like to send any command (say, print Hello World) to the Terminal of the MacBook.
How to do this and what would be the command syntax (or package needed)?
There is no single package to do this.
At a minimum, your Mac host would need to run a server process. Then the VM would need to be on a host network bridge such that it is remotely addressable. Then, you can write a client that sends RPC requests to the host's server process.
At a low-level, you can use socket library, but you may want something higher level like httpserver.
Related - VMWare fusion: connecting to host's web server from guest
The other option without external dependencies would be to communicate over a file-system share.
If you want to install external software, then you can introduce a remote message queue or database.

USB Device/PyUSB on Windows and LInux behaving differently

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.

Python using gattlib for BLE Scanning on Windows 10

I want to create a BLE Connection between my Laptop (Windows 10) and a BLE Device which will be the Master.
I installed Bluez and I can detect Bluetooth devices like my Smartphone but no device that only supports BLE. I want to download gattlib with pip install gattlib but I got an OSError: Not supported OS which brings me to the conclusion that I can't do it this way on Windows 10. Is there any other possibility than installing Linux on my Laptop?
gattlib is controlling bluez via dbus, bluez is linux only, so gattlib can't be used on windows.
gattlib is basically wrapper for the dbus api of bluez in python.
use vm instead and mount your bt adapter to the vm in order to control it with bluez.
wsl isn't supporting bluez right now
Windows 11 and Android - BluetoothAdapter return null
The operating you are using is not compatible. Gattlib only work with linux due to it relying on bluez whcih work on linux only. What you can do is using WSL on windows.
As far as I know, gattlib is designed for linux and debian system so you can use another one. Another side, if you are using a Python version greater than 3.9, you can directly Bluetooth RFCOMM Support for Windows 10.
I think you can find a solution by using "vmware" or "virtualbox" programs.
Output that I tested for you:

Connect PySerial to Bluetooth COM port via BlueSoleil on Windows 7

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.

Open URL command from Linux to Windows in Python

I have a Linux PC (running Ubuntu) and a Windows 7 PC, and they are connected to the same network.
I want to write a script in Python from the Linux PC that "tells" the Windows PC to open a specific URL.
I know the command in windows is e.g. "start www.google.com", so I think I have to somehow send this command from the Linux to the Windows PC using a Python script.
Thanks in advance for any suggestions!
Well, how the PC's connected, LAN, WAN, Bluetooth? I assume they use a LAN. In this case you can use a socket library to send data from one PC to another.
The Linux will be a client and Win7 will be a server, check this link for example: Server/Client implementation

Categories