Hi all,
I work on project that needs a rpi4 to communicate with a measurement device over USB. Everything is working well except sometimes when I download “a lot” of data the device doesn’t respond anymore and I can’t reconnect to it until I unplug and replug. I use pyserial and there are no error reported, neither from dmesg, or pyserial. There’s just nothing! The same code is working well on my laptop.
The code:
def CmdDownloadSectorData(self, numSector, keepPortOpen = False):
if self.CmdDownloadSector(numSector, True) is False:
return False
retry = 0
buf = bytearray([])
try:
while len(buf) < self.SectorSize and retry < 10:
while self.SerialPort.in_waiting <= 0 and retry < 10:
sleep(0.3)
retry = retry + 1
# afer a while , there's just nothing in_waiting and I can't reach the device anymore
try:
buf = bytearray(self.SerialPort.read(self.SectorSize - len(buf)))
except serial.SerialException:
return False
except serial.SerialTimeoutException:
print("timeout")
retry = retry + 1
except OSError:
return False
if not keepPortOpen:
print("Serial Port is being closed !")
self.SerialPort.close()
if len(buf) != self.SectorSize:
return False
return bytes(buf)
This function is called on every 256 sectors of the device. It’s randomly stuck at a sector, once it even succeeded!
The RPi runs Manjaro KDE ARM and my laptop Manjaro KDE.
I updated the rpi eeprom to the latest and pacman -Syu.
[pi@raspberrypi ~]$ sudo rpi-eeprom-update
[sudo] password for pi:
BOOTLOADER: up to date
CURRENT: Thu Apr 29 04:11:25 PM UTC 2021 (1619712685)
LATEST: Thu Apr 29 04:11:25 PM UTC 2021 (1619712685)
RELEASE: critical (/lib/firmware/raspberrypi/bootloader/critical)
Use raspi-config to change the release.
VL805_FW: Dedicated VL805 EEPROM
VL805: up to date
CURRENT: 000138a1
LATEST: 000138a1
Dmesg with the device connected, the bug occured then I unplugged the device.
/boot/config.text
# See /boot/overlays/README for all available options
gpu_mem=64
initramfs initramfs-linux.img followkernel
kernel=kernel8.img
arm_64bit=1
disable_overscan=1
#enable sound
dtparam=audio=on
#hdmi_drive=2
#enable vc4
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
disable_splash=1
lcd_rotate=2
enable_uart=1
/boot/cmdline.text
root=PARTUUID=2a586bd1-02 rw rootwait selinux=0 quiet splash plymouth.ignore-serial-consoles smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 elevator=noop usbhid.mousepoll=8 snd-bcm2835.enable_compat_alsa=0 audit=0 dwc_otg.speed=1
I’ve tried to change some kernel parameters etc but nothing helps…
Thank you for your help! Cheers