barbeker
Posts: 12
Joined: Thu Sep 10, 2015 7:37 am

how to score higher baude rate with serial RPI2RPI

Mon Mar 14, 2016 9:29 am

I'm rather new to RPI and python and I could really use your help, so thanks in advance. So my project main goal is to transmit data (a jpeg file for instance) from one RPI 2 to another one asynchronously. Currently I'm using the UART pins and a simple python program, which its main modulus are:

#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

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: how to score higher baude rate with serial RPI2RPI

Mon Mar 14, 2016 9:32 am

viewtopic.php?f=44&t=51633

though for high speed use the Ethernet
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

barbeker
Posts: 12
Joined: Thu Sep 10, 2015 7:37 am

Re: how to score higher baude rate with serial RPI2RPI

Mon Mar 14, 2016 10:21 am

RaTTuS wrote:viewtopic.php?f=44&t=51633

though for high speed use the Ethernet
thank you for your replay i did reat that post but the thing is i need the RPIS to stand alone without any network involved

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: how to score higher baude rate with serial RPI2RPI

Mon Mar 14, 2016 11:02 am

you can use the Ethernet with no network - setup dhcpd so one machines acts as a server and the other as a client
or both have static ips
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: how to score higher baude rate with serial RPI2RPI

Tue Mar 15, 2016 11:57 am

How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

Return to “Beginners”