Raspberry Pi Serial Port Uarts
Raspberry Pi Enable Uart
This problem is quite complicated. Seemingly I have simple two-way communication beetwen 2 devices where reading side is Raspberry pi 3. I'm trying to transfer file. I'm sending it part by part (5kb part). It looks like: 1) Sending side send first 5kb part (exactly 5136 bytes where first 16 bytes are ID/SIZE/ADDINFO/CRC) 2) RPi3 read 5136 bytes, and calculate CRC for chunk. 3) RPi3 compare CRC received from sending side and calculated by RPi 4a) If CRC doesn't match I switch lanes from RX to TX line using Dual Bus Buffer Gate With 3-State Outputs and set High State at TX line (I keep it for 30ms). 4b) If CRC match I just wait for next chunk of file 5) Sending side switch lanes too and read my TX state if state is HIGH/1 (when CRC doesn't match) it sends same chunk (retransmission) if state is LOW/0 sends another chunk.
Raspberry Pi Uart Console
Gta san andreas modded torrent. (changing state take 10 ms) On osciloscope it looks like this (4a): and this (4b): Beetwen 5136 chunk there is free time to calculate CRC then we have on RPi3 side changing state if we have to because CRC doesn't match (red lines at 4a) and reading TX side from Sending side. Ok now some simplified code from RPi: def recv: while True: #Set line to low because I want to read data GPIO.output(16, GPIO.LOW) ID = ser.read(4) SIZE = ser.read(4) ADDINFO = ser.read(4) CRC = ser.read(4) #get crc from sending side crcchunk = int.frombytes(CRC, byteorder='little') data = ser.read(5120) #calculating CRC from chunk rpiCRC = crcSTM(data) while True.