Skip to content
Snippets Groups Projects
Commit ac2e1562 authored by Jake Read's avatar Jake Read
Browse files

start uart

parent 880b2451
Branches
No related tags found
No related merge requests found
## 2023 12 29
So, spinning this up is pretty simple (on the pi 4) we use the configuration tool (UI version actually shows the options we want, command line version misses one) to set UART and SPI interfaces available, then the test code is just using pyserial:
```python
import serial, time
baud = 2000000
print(f'bit time should be {1000000/baud}us')
ser = serial.Serial('/dev/serial0', baud)
for i in range(10000):
ser.write(bytearray([95]))
time.sleep(0.001)
ser.close()
```
Now, I'm trying to figure where the limit is, so, baud values and measured bit times:
| Baud Setting | Expected Bit Time | Measured | Match |
| --- | --- | --- | --- |
| 115200 | 8.681us | 8.703us | 0.997 |
| 1000000 | 1.0us | 1.024us | 0.977 |
| 2000000 | 500ns | 512ns | 0.977 |
| 3000000 | 333ns | 352ns | 0.946 |
| 4000000 | 250ns | 271ns | 0.922 |
| 5000000 | 200ns | 223ns | 0.923 |
| 6000000 | 166ns | 176ns | 0.943 |
| 10000000 | 100ns | 111ns | 0.901 |
So we can actually get up to ~ 5MBit/sec and (nearly) survive, though baud settings might need to be trimmed on a scope to get-robust. This is a pretty good sign, and it means we can probably make a serviceable link using UART, though we might end up wanting to deploy two. I'll see quickly about the SPI speeds and then try to figure out where to push.
\ No newline at end of file
import serial, time
baud = 10000000
print(f'bit time should be {1000000/baud}us')
ser = serial.Serial('/dev/serial0', baud)
for i in range(10000):
ser.write(bytearray([95]))
time.sleep(0.001)
ser.close()
\ No newline at end of file
import serial.tools.list_ports
def list_serial_ports():
ports = serial.tools.list_ports.comports()
print(f"Total Ports: {len(ports)}")
for port in ports:
print(f"Port: {port.device}")
print(f" - Description: {port.description}")
if port.serial_number:
print(f" - Serial Number: {port.serial_number}")
if port.manufacturer:
print(f" - Manufacturer: {port.manufacturer}")
if port.product:
print(f" - Product: {port.product}")
if port.vid is not None:
print(f" - VID: {port.vid:04X}")
if port.pid is not None:
print(f" - PID: {port.pid:04X}")
print()
list_serial_ports()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment