Can't open more then 34 serial ports on Raspberry Pi 4B

53 Views Asked by At

Apologies first for the bad written code. I am a beginner.

I tried to open 48 serial USB devices at the same time with this code:

# performance.py

#import der Libarys 
import serial                                                       
import time 
import sys                                                      


serialInterfaces = [] 

basicpath = "/dev/ttyUSB"
portnum = 47

def close():
    for serialIf in serialInterfaces:
        serialIf["if"].close()

def Init():
    portnumbers = range(portnum)
    for port in portnumbers:
        serialIf = {
            "path": basicpath + str(port),
        }
        serialIf["if"] = serial.Serial(serialIf.get("path"), baudrate=1200, timeout=1)

        serialInterfaces.append(serialIf)
        print(str(serialIf))


Init()
close()

But after opening 34 serial ports, the raspberry pi collapses.

Does anyone know what mistake I made or is the raspberry pi just too weak?

Thanks for the help!

0

There are 0 best solutions below