Hello
I am using Raspberry Pi and I have downloaded the Raspberry Pi Host OS from BalenaOS download page.
Raspberry Pi Version =>
BalenaOS 2.36.0+rev2
I have to set up communication between External hardware with Raspberry Pi using the UART interface.
For that I have done the following settings in config.txt =>
enable_uart=1
core_freq=250
dtoverlay=pi3-miniuart-bt
dtoverlay=uart-ctsrts
using Balena Cli env add
command
I am using pi3-miniuart-bt
for switching the Port for swapping ttyAMA0
and ttyS0
uart-ctsrts
are used to enable Hardware flow control.
I have copied miniuart-ctsrts.dtbo
and uart-ctsrts.dtbo
in the /mnt/boot/overlays
directory.
I have enabled the UART and wrote a sample code for send and receiving the bytes over receiving.
Send function works properly But receiving function blocks after 2 to 3 seconds.
#!/usr/bin/env python
import time
import serial
ser = serial.Serial(
port='/dev/serial0',
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
counter=0
while 1:
print "I am reading"
x=ser.readline()
print "I am after reading"
print(x)
#!/usr/bin/env python
import time
import serial
ser = serial.Serial(
port='/dev/serial0',
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
counter=0
while 1:
print "I am here"
ser.write('Write counter: %d \n'%(counter))
time.sleep(10)
counter += 1