I have an Onion Omega2 device acting as a linux server that has a UART stream from an Arduino chip. Through the terminal on my laptop I can connect via SSH and stream the data from the UART coming into the device. I then attempted to create an SSH shell in Python using Paramiko. Code shown below:
import paramiko
def ssh_comm(ip, usr, passwd):
client = paramiko.SSHClient();
client.set_missing_host_key_policy(paramiko.AutoAddPolicy());
client.connect(ip, username=usr, password=passwd);
channel = client.invoke_shell();
channel.send("screen /dev/ttyS1 9600 \n");
print("/n");
points = 0;
while points < 100:
if channel.recv_ready():
print(channel.recv(1024));
points = points + 1;
channel.shutdown(2);
client.close();
return;
ssh_comm("192.xxx.x.x", "root", "password");
First time around it connects well and all data is streamed back to my laptop. However when I let the shell close and then re-open it I only recieve a few packets every now and then back from the Omega2. (It still connects fine though) After connecting through python the transmission is also intermittent when forming the SSH connection on the terminal using: ssh root@192.xxx.x.x
.
Restarting the Omega 2 fixes this however since I can repeatedly connect though the terminal with no issues I beleive the problem must be to do with closing the session within the python code. Or not configuring it properly. Having looked through the paramiko docs and tried my best to configure it correctly I still get the same issue. Any ideas as to what could be causing it?