Difference between revisions of "Serial Hack"

From LinuxMCE
Jump to: navigation, search
m (Comments)
(go find something usefull to do, instead of pestering people that actually add information)
Line 28: Line 28:
 
tree -fi /dev | grep ttyUSB
 
tree -fi /dev | grep ttyUSB
 
</pre>
 
</pre>
 +
 +
== Comments ==
 +
 +
If someone out there has a better way of doing this, please post it here! -AVJohn
 +
 +
----
 +
How about:
 +
cat >/usr/pluto/bin/ListSerialPorts.sh <<"EOF"
 +
#!/bin/bash
 +
 +
tree -fi /dev | grep ttyS
 +
tree -fi /dev | grep ttyUSB
 +
EOF
 +
 +
That should overwrite the file in one go, without having to use vi.
 +
--[[User:Zaerc|Zaerc]] 04:53, 20 September 2007 (MST)
 +
 +
  
 
[[Category: GSD]]
 
[[Category: GSD]]
 
[[Category: LinuxMCE_Devices]]
 
[[Category: LinuxMCE_Devices]]
 
[[Category: Programmer's Guide]]
 
[[Category: Programmer's Guide]]

Revision as of 21:00, 21 September 2007

Serial List Hack

In some situations, (which, I might add are becoming more and more common now) a core or core/hybrid may not have enough, or indeed, any serial ports for automation kit such as the X10 modules to jack into.

In these cases a USB-to-Serial converter may be used, but LinuxMCE does not list these correctly in its admin pages. This is due to the script "/usr/pluto/bin/ListSerialPorts.sh" which creates the list of serial ports, not giving the correct path (usually /dev/ttyUSB#, where # is a number).

A simple replacement, which, while inferior to the current script in that it does not detect the ports in use, does correctly list all serial ports, both USB and normal serial. However, it requires the 'tree' command, so:


sudo apt-get install tree


Once that has completed, tree will have been installed, and we can use its '-fi' mode to produce full paths, then it is just a simple matter of removing the origional ListSerialPorts.sh file and writing our own, I use vim for this, but any other terminal or graphical text editor will do the job:


sudo rm /usr/pluto/bin/ListSerialPorts.sh
sudo vim /usr/pluto/bin/ListSerialPorts.sh


Now that vim is open, enter the following:


#!/bin/bash

tree -fi /dev | grep ttyS
tree -fi /dev | grep ttyUSB

Comments

If someone out there has a better way of doing this, please post it here! -AVJohn


How about:

cat >/usr/pluto/bin/ListSerialPorts.sh <<"EOF"
#!/bin/bash

tree -fi /dev | grep ttyS
tree -fi /dev | grep ttyUSB
EOF

That should overwrite the file in one go, without having to use vi. --Zaerc 04:53, 20 September 2007 (MST)