Communication with baudrate 110

2

I have to receive data from an equipment that has a TTL interface that sends the data to 110 bits per second.

In all the tests I performed when trying to reach this speed I have problems, for example:

  • My program does not receive the 9 bytes sent, only 8 bytes and what it receives does not match what should.

  • With Arduino (ide v1.6 and v1.8) when I send something by the serial at 300 bits per second it only goes nonsense, any other speed works (so sending a simple Serial.println ("hi "))

Any idea of what might be happening?

    
asked by anonymous 23.01.2018 / 20:07

1 answer

0

One option is to use the Python language using the pyserial module. It is a very versatile module, able to receive various configurations of serial communication and standards.

A sample Python code using serial below:

import serial

class Comunicacao():

    def SerialInit(self, NomePorta, Velocidade, TimeRX, TimeTX):

        try:
            self.PortaCom = serial.Serial(NomePorta, Velocidade, 8, serial.PARITY_NONE, serial.STOPBITS_ONE, TimeRX,
                                          False, False, False, TimeTX)
            self.PortaCom.reset_input_buffer()
            self.PortaCom.reset_output_buffer()

        except Exception:
            print("Erro na porta " + NomePorta + "!")



    def WriteSerial(self, DadosTx):

        try:
            self.PortaCom.flushOutput()
            TamPac = DadosTx[3]
            for i in range(TamPac):
                DadoTxByte = bytes((DadosTx[i],))

                self.PortaCom.write(DadoTxByte)
                print(DadoTxByte)

        except Exception:
            print("Erro Escrita")

    def Leitura_Serial(self, DadosRx):

        LeituraSerial = [0] * 200

        for i in range(200):

            if (self.PortaCom.in_waiting > 0):
                LeituraSerial[i] = self.PortaCom.read()
                LeituraSerial[i] = self.ByteToInt(LeituraSerial[i])
                print(LeituraSerial[i])

            else:
                break

DadosTx = [1,2,3,4,5,6,7,8]
DadosRx = [0] * 100
PortaCom = Comunicacao()
PortaCom.SerialInit("/dev/ttyUSB0", 115200, 1, 1)
PortaCom.WriteSerial(DadosRx)
    
26.01.2018 / 16:23