I am currently working on a software that uses a barcode scanner reading from an Ubuntu serial port. The service is hosted inside a k3s pod. The scanner is set to a baud rate of 115200, and the port is set up through minicom for 115200.
When I try change the baud of the port using stty -F /dev/ttyS6 115200
while the service is not running it works. But when I start the service it resets the baud rate to 9600:
speed 9600 baud; line = 0; intr = <undef>; quit = <undef>; erase = <undef>; kill = <undef>; eof = <undef>; start = <undef>; stop = <undef>; susp = <undef>; rprnt = <undef>; werase = <undef>; lnext = <undef>; discard = <undef>; min = 1; time = 0; -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
Here is my k3s deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: serial-scanner # name of the deployment
spec:
selector:
matchLabels:
app: serial-scanner # label to match
template:
metadata:
labels:
app: serial-scanner # label to apply
spec:
volumes:
- name: serialports-utils
persistentVolumeClaim:
claimName: serialports-pvc
- name: ttys0
hostPath:
path: /dev/ttyS0
- name: ttys1
hostPath:
path: /dev/ttyS1
- name: ttys2
hostPath:
path: /dev/ttyS2
- name: ttys4
hostPath:
path: /dev/ttyS4
- name: ttys5
hostPath:
path: /dev/ttyS5
- name: ttys6
hostPath:
path: /dev/ttyS6
hostname: serialscanner
hostNetwork: true # this allows the pod to use the Hub's network stack
containers:
- name: serial-scanner # this will be the interal DNS label of the pod
securityContext:
privileged: true
image: serial_scanner # name of image to use. Should later be version controlled
imagePullPolicy: IfNotPresent # this will pull the image from the local registry first and then from the internet
ports:
- name: grpc
containerPort: 3000
volumeMounts:
- mountPath: /dev/ttyS0
name: ttys0
readOnly: true
- mountPath: /dev/ttyS1
name: ttys1
readOnly: true
- mountPath: /dev/ttyS2
name: ttys2
readOnly: true
- mountPath: /dev/ttyS4
name: ttys4
readOnly: true
- mountPath: /dev/ttyS5
name: ttys5
readOnly: true
- mountPath: /dev/ttyS6
name: ttys6
readOnly: true
- mountPath: /serialscanner/utils
name: serialports-utils
---