#initiating the serial port
Code: Select all
self.ser = serial.Serial(
port='/dev/ttyUSB0',
baudrate= int(self.baudRate),
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
rtscts=False,
dsrdtr=False
)#writing data to the port
Code: Select all
f=open(self.filename, 'rb')
data=f.read()
data_length=str(len(data)) #writing the size of the file I wish to send
data_length1=str(len(data_length))
size=data_length1+data_length
self.ser.write(size) #writing the size of the file I wish to send
for b in data:
self.ser.write(b))
#reading data from the port
Code: Select all
file=open(self.filename, 'wb')
first=int(self.ser.read(1))
file_l=int(self.ser.read(first)) # figuring the size of the file
data=self.ser.read(1)
for i in range (1,file_l):
data+=self.ser.read(1)
file.write(data)
the thing is that no matter how high I set the baud rate, I couldn’t get a writing rate of over 380Kbps. When I didn't use the "for" loop on the transmitter moudule, It seemed that the writing was indeed faster, but then the receiver couldn't read anything. Any advices on how to reach higher rates?
thank you very much and please forgive my English