Traditionally in Linux, the first serial port (COM1) is assigned a name /dev/ttyS0, the second serial port (COM2) assigned /dev/ttyS1, etc. If you specify a serial port name as the first argument of the screen command, the current terminal window where you run screen will be directly connected to the serial port.
Question: I need to access the management terminal of a hardware switch/router (e.g., Cisco Catalyst or HP ProCurve) via its console port. The switch console port is connected to the serial port of my Linux box. How can I connect to the serial port from a Linux terminal?
First of all, let's assume that you have already connected the serial port of your Linux box to a switch console port via a serial cable.
To connect a Linux terminal to the serial port of your Linux system, you can use a command-line screen manager tool called screen.
The serial port communication programs moserial or gtkterm provide an easy way to check connectivity and modify /dev/ttyUSB0 (or /dev/ttyUSB1!) settings. Even though there maybe only a single USB to RS232 adapter, the n designation /dev/ttyUSBn can and does change periodically! Introduction To use Python as a graphical interface for an Arduino powered robot, programmatically read the USB with the pySerial library. However, waiting for input from pySerial's Serial object is blocking, which means that it will prevent your GUI from being responsive.
Install screen on Linux
To install screen on Debian, Ubuntu or Linux Mint:
To install screen on CentOS, Fedora, or RHEL:
$ sudo yum install screen
Connect to a Serial Port with screen utility
Traditionally in Linux, the first serial port (COM1) is assigned a name /dev/ttyS0, the second serial port (COM2) assigned /dev/ttyS1, etc. If you specify a serial port name as the first argument of the screen command, the current terminal window where you run screen will be directly connected to the serial port.
Thus, to connect to a serial port, simply run the following command from a terminal:
Linux Serial Communication Gui Tutorial
Optionally, you can specify baud rate (e.g., 1200, 9600, 19200) as the second parameter as follows.
$ screen /dev/ttyS0 9600
Once connected to a serial port, you will then be able to access the switch console port from the terminal.
To terminate the current screen session, type 'Ctrl-A'+'k'. If you want to temporarily detach from the screen session, type 'Ctrl-A'+'d'. After detached, you can re-attached to the session later by running:
Download this article as ad-free PDF (made possible by your kind donation):
Subscribe to Ask Xmodulo
Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.
Support Xmodulo
Did you find this tutorial helpful? Then please be generous and support Xmodulo!
Label templates are used to accurately position text and images when printing labels on A4 sheets. If you want labels that match a particular Avery size or want/need to use an Avery template to print your labels, you can buy labels from us safe in the knowledge that they are completely compatible with their Avery equivalents. You can also use our to give our labels a try and see for yourself.Our label templates and printing guides are completely FREE resources for anyone to use; if you find these pages helpful, why not let others know by mentioning us on social media or adding a link to us on your website or blog, to help us maintain these pages as a helpful resource for as many people as possible. Label Planet templates are accurate and compatible with standard label sizes and can be downloaded for free in MS Word and PDF formats.Label Planet is a UK label supplier specialising in labels on A4 sheets. If you are an existing customer then many thanks for coming back; please let us know if we can assist in any way, particularly if you are looking for something different. Download avery label template 8160.
Introduction
To use Python as a graphical interface for an Arduino powered robot, programmatically read the USB with the pySerial library. However, waiting for input from pySerial's Serial object is blocking, which means that it will prevent your GUI from being responsive. The process cannot update buttons or react to input because it is busy waiting for the serial to say something.
The first key is to use the root.after(milliseconds) method to run a non-blocking version of read in the tkinter main loop. Keep in mind that when TkInter gets to the root.mainloop() method, it is running its own while loop. It needs the things in there to run every now and then in order to make the interface respond to interactions. If you are running your own infinite loop anywhere in the code, the GUI will freeze up. Alternatively, you could write your own infinite loop, and call root.update() yourself occasionally. Both methods achieve basically the same goal of updating the GUI.
However, the real issue is making sure that reading from serial is non-blocking. Normally, the Serial.read() and Serial.readline() will hold up the whole program until it has enough information to give. For example, a Serial.readline() won't print anything until there is a whole line to return, which in some cases might be never! Even using the after() and update() methods will still not allow the UI to be updated in this case, since the function never ends. This problem can be avoided with the timeout=0 option when enitializing the Serial object, which will cause it to return nothing unless something is already waiting in the Serial object's buffer.
CodeComments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |