Differences between pyserial 2.3 and 2.7? - pyserial

can someone list the differences between pyserial 2.6 and pyserial 2.7
I'm unable to get the release notes for both the releases.

The list is maintained in CHANGES.rst on GitHub.
Version 2.7 2013-10-17
Win32: setRTS and setDTR can be called before the port is opened and it will set the initial state on port open.
Posix: add platform specific method: outWaiting (already present for Win32)
Posix: rename flowControl to setXON to match name on Win32, add flowControlOut function
rfc2217: zero polls value (baudrate, data size, stop bits, parity) (Erik Lundh)
Posix: [Patch pyserial:28] Accept any speed on Linux [update]
Posix: [Patch pyserial:29] PosixSerial.read() should "ignore" errno.EINTR
OSX: [Patch pyserial:27] Scan by VendorID/Product ID for USB Serial devices
Ensure working with bytes in write() calls
Bugfixes:
[Bug 3540332] SerialException not returned
[Bug pyserial:145] Error in socket_connection.py
[Bug pyserial:135] reading from socket with timeout=None causes TypeError
[Bug pyserial:130] setup.py should not append py3k to package name
[Bug pyserial:117] no error on lost conn w/socket://
Bugfixes (posix):
[Patch 3462364] Fix: NameError: global name 'base' is not defined
list_ports and device() for BSD updated (Anders Langworthy)
[Bug 3518380] python3.2 -m serial.tools.list_ports error
[Bug pyserial:137] Patch to add non-standard baudrates to Cygwin
[Bug pyserial:141] open: Pass errno from IOError to SerialException
[Bug pyserial:125] Undefined 'base' on list_ports_posix.py, function usb_lsusb
[Bug pyserial:151] Serial.write() without a timeout uses 100% CPU on POSIX
[Patch pyserial:30] [PATCH 1/1] serial.Serial() should not raise IOError.
Bugfixes (win32):
[Bug 3444941] ctypes.WinError() unicode error
[Bug 3550043] on Windows in tools global name 'GetLastError' is not defined
[Bug pyserial:146] flush() does nothing in windows (despite docs)
[Bug pyserial:144] com0com ports ignored due to missing "friendly name"
[Bug pyserial:152] Cannot configure port, some setting was wrong. Can leave port handle open but port not accessible

Related

VS Code randomly starts listening on high port on 0.0.0.0

VS code often starts listening on a random high port on all interfaces.
$ lsb_release -d
Description: Ubuntu 22.04 LTS
$ code --version
1.67.2
c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5
x64
$ sudo ss -ltpn | grep code
LISTEN 0 511 *:33333 *:* users:(("code",pid=75602,fd=52))
In VS code developer tools console:
CRITI Extension 'ms-vsliveshare.vsliveshare' wants API proposal 'notebookDocumentEvents' but that proposal DOES NOT EXIST. Likely, the proposal has been finalized (check 'vscode.d.ts') or was abandoned.
log.ts:313
ERR UnboundLocalError: local variable 'start_index' referenced before assignment: Error: UnboundLocalError: local variable 'start_index' referenced before assignment
at /home/user/.vscode/extensions/ms-python.python-2022.8.0/out/client/extension.js:2:2107873
at /home/user/.vscode/extensions/ms-python.python-2022.8.0/out/client/extension.js:2:2108167
at Immediate.<anonymous> (/home/user/.vscode/extensions/ms-python.python-2022.8.0/out/client/extension.js:2:2108529)
at processImmediate (node:internal/timers:464:21)
log.ts:313
ERR Error: File not found
at g.handleSetInputError (vscode-file://vscode….main.js:2701:95592)
at async g.setInput (vscode-file://vscode….main.js:2701:94832)
at async doSetInput (vscode-file://vscode…p.main.js:2699:6429)
at async doOpenEditor (vscode-file://vscode…p.main.js:2699:4791)
at async d.openEditor (vscode-file://vscode…p.main.js:2699:3783)
at async vscode-file://vscode….main.js:2906:16950
at async bi.openAnything (vscode-file://vscode….main.js:2712:17542)
I have not been able to reproduce whenever the Microsoft Python extension (Python
v2022.8.0) was disabled, so it might be related to that. There is an error in the console related to ms-python, but I do not immediately see how it would lead to a port being opened, especially not on 0.0.0.0.
The following shows nothing:
$ sudo tcpdump -i any port 33333
The question is what causes this port to be opened (and how to avoid this).
In the process explorer of VS code it shows that the process that opened the port is 'extensionHost'.

Cannot send command IR with HotPI

I bought a HotPi a while ago, and decided to use it. So I followed the procedure to configure the IR and after a few hours I was able to IR signals on my Raspberry 1.
But my purpose here is to send IR signals, which I tried, without any luck.
So this is the command I try to do (just for test):
irsend SEND_START devinput KEY_POWER ; sleep 3
And this is what lircd tells me:
lircd-0.9.4c[907]: Notice: accepted new client on /var/run/lirc/lircd
lircd-0.9.4c[907]: Info: Cannot configure the rc device for /dev/lirc0
lircd-0.9.4c[907]: Error: invalid send buffer
lircd-0.9.4c[907]: Error: this remote configuration cannot be used to transmit
lircd-0.9.4c[907]: Error: error processing command: SEND_START devinput KEY_POWER
lircd-0.9.4c[907]: Error: transmission failed
lircd-0.9.4c[907]: Info: removed client
Edit:
It seems I'm not using the good drivers. According to the HotPi documentation, I'm suppose to use lirc-rpi, which I'm suppos to install with
sudo modprobe lirc-rpi
Which, at least, doesn't return an error. But trying to configure the interface tells me that the driver doesn't exist:
pi#raspberrypi:~ $ mode2 --driver lirc-rpi --device /dev/lirc0
Driver `lirc-rpi' not found. (Missing -U/--plugins option?)
Available drivers:
accent
alsa_usb
asusdh
atilibusb
atwf83
audio
audio_alsa
awlibusb
bte
bw6130
commandir
creative
creative_infracd
default
devinput
dfclibusb
dsp
dvico
ea65
file
ftdi
ftdi-exp
ftdix
girs
i2cuser
irlink
irtoy
livedrive_midi
livedrive_seq
logitech
macmini
mouseremote
mouseremote_ps2
mp3anywhere
mplay
mplay2
pcmak
pinsys
pixelview
samsung
sb0540
silitek
slinke
sonyir
srm7500libusb
tira
tira_raw
udp
uirt2
uirt2_raw
usb_uirt_raw
usbx
zotac
Here is no info what lirc version you are using. There are vast differences between the legacy 0.9.0 still used in some distros and modern lirc.
That said, the logs seems pretty clear. You are using the devinput driver, right? This driver does not support sending data, reflecting the fact that also the kernel doesn't.
You then need to use another driver - first stop might be the default one. If/when using this other driver, you need another lircd.conf.
Please refer to http://lirc.org/html/configuration-guide.html
EDIT: Ah, lirc-0.9.4c says the log. Sorry, my bad. The reply should still be valid, though.
When you record the remote, use:
irrecord -d /dev/lirc0 -f name.conf
The -f uses raw mode. This then worked for me on the transmit side, before I got same error as you.

pyusb - [Error 5] on Linux, but not Windows

I'm trying to communicate with an AD9913 evaluation board (Analog Devices), which has a Cypress FX-2 USB controller. I wrote a fully functional Python library which works flawlessly on Windows 7 (using a driver generated through libusb-win32-1.2.6.0's inf-wizard.exe), but now I try to run the same software from a Raspberry Pi 3 with Raspbian Jessie and cannot seem to write or read.
The following minimal example works on Windows 7:
import os
os.environ['PYUSB_DEBUG'] = 'debug'
import usb.core
print "usb.core file:", usb.core.__file__
# get device
dev = usb.core.find(idVendor=0x0456, idProduct=0xEE25)
if dev is None:
raise ValueError("Device not found")
dev.set_configuration()
# get the firmware version
print "Write: ", dev.write(0x01, [0x00])
print "Read: ", dev.read(0x81, 7)
The ouput here is:
usb.core file: C:\Python27\lib\site-packages\usb\core.pyc
Write: 1
Read: array('B', [1, 0])
However, on the Raspberry several problems occur. First, the product ID is 0xEE24 (which I found out through dmesg), and second, the code example above gives
usb.core file: /usr/local/lib/python2.7/dist-packages/usb/core.pyc
Write:
Traceback (most recent call last):
File "usbtesting_minimal_linux.py", line 29, in <module>
print "Write: ", dev.write(0x01, [0x00])
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 948, in write
self.__get_timeout(timeout)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 824, in bulk_write
timeout)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 920, in __write
_check(retval)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 5] Input/Output Error
I'm executing the script by calling sudo python minimal_example.py, otherwise (as expected) I get usb.core.USBError: [Errno 13] Access denied (insufficient permissions). (For the testing described above, I removed the udev rules I added to allow access to my regular user account, and rebooted and replugged the device afterwards.)
I also noticed that on Windows, Configuration 1 (which is the only configuration) as revealed by adding
cfg = dev.get_active_configuration()
to aforementioned example script, has only one Interface 0, where as on Linux Interface 0 has no endpoints, but there are additional interfaces Interface 0, 1, Interface 0, 2 and Interface 0,3, the first of which is identical to the sole interface shown by Windows.
Detaching kernel drivers as described in this post -- which given my current understanding as a USB novice should not be necessary here -- does not resolve the problem.
I suspect that the issue stems from a difference between the Windows/libusb and Linux implementation/backend of the USB communication (already hinted at by the fact that the productID shown is different for the very same piece of hardware attached), which might require some changes to the way I'm writing to the USB endpoint.
I'm happy to provide more information if needed and welcome all hints and suggestions.
Most likely, this error caused by the firmware is not uploaded. Usually speaking, FX-2 USB controller does not save the firmware.
Although I still cannot communicate with the device on the Raspberry Pi, the Error 5 problem is resolved by explicitly selecting a suitable alternate setting with proper endpoints, e.g.
dev.set_interface_altsetting(interface = 0, alternate_setting = 1)
Then read/write requests no longer fail with Error 5, but with a timeout error (which is Error 110 for libusb1 and None for libusb0).
I now suspect that there is a problem with how the device is detected by the operating system, since not only the productID changes between Windows and Linux, but also wMaxPacketSize for the endpoints I'm interested in is given as 64 bytes on Windows and 512 bytes on Linux.
Once I'm further along in my troubleshooting, I will either open a new question and add the link as a comment to this answer (or post the whole solution here in case I can solve everything right away).

How to fix Storable version discrepancy of a DBI Proxy connection?

I got a connection test script that is run on my client system and is calling a Perl DBI Proxy server via
my $dbh = DBI->connect("dbi:Proxy:$dbiproxy;dsn=$dsn", "$user","$pass",{ PrintError => 1}) || ($errmsg = "ERROR on connect");
When running the script it will fail stating
connect('hostname=***;port=2001;dsn=dbi:Oracle:***','***',...) failed: Cannot log in to DBI::ProxyServer: Unexpected EOF from server at /usr/local/share/perl/5.10.1/RPC/PlClient.pm line 79.
The log on the DBI Proxy server reads
Wed Dec 15 14:47:47 2015 err, Child died: Storable binary image v2.7 more recent than I am (v2.6) at blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/thaw.al) line 363, at /usr/lib/perl5/site_perl/5.8.0/RPC/PlServer/Comm.pm line 179
So I checked the Perl and Storable module version numbers of the two systems and the DBI proxy server seems to be rather outdated:
source: perl 5.10.1, storable 2.20, storable 2.7 (binary), Debian 6.0
target: perl 5.8.0 , storable 2.13, storable 2.6 (binary), RHEL 3
The problem is that I can not update the module/perl version of the target system, so I thought I could simply lower the utilized client version by modifying the /usr/local/share/perl/5.10.1/RPC/PlServer/Comm.pm file and change the line
require Storable;
to
use Storable 2.13;
but this will result in the same error as above. I also tried to use Storable 2.13 directly in my Perl test-script, but that does not change anything, either.
When googling this I could not find any solution, only confirmation that this version discrepancy can be a problem. Increasing the DBI_TRACE level on the client side also did not reveal anything new. Frankly I don't know what to try next and any help would be greatly appreciated.

Is Net::SFTP failing because of SSH?

I have trouble connecting with Net::SFTP to a remote server. I ran the same script before on another machine with success, however, I get now the following error:
[root#script-server fmzbih_cms_weather_updater]# ./fmzbih_cms_forecast.pl
script-server.bih.net.ba: Reading configuration data /root/.ssh/config
script-server.bih.net.ba: Reading configuration data /etc/ssh_config
script-server.bih.net.ba: Allocated local port 1023.
script-server.bih.net.ba: Connecting to 10.100.4.193, port 22.
script-server.bih.net.ba: Remote protocol version ., remote software version
script-server.bih.net.ba: Net::SSH::Perl Version 1.34, protocol version 1.5.
script-server.bih.net.ba: No compat match: .
script-server.bih.net.ba: Connection established.
Can't locate object method "_session_channel" via package "Net::SSH::Perl::SSH1" at /usr/local/lib/perl5/site_perl/5.14.2/Net/SFTP.pm line 78.
Could this be because of SSH1 being used as shown in log? Shouldn't SFTP use SSH2?