<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Digivation Hack Central &#187; udev</title>
	<atom:link href="http://blog.digivation.com.au/category/tag/udev/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.digivation.com.au</link>
	<description>Tech Information about various subjects</description>
	<lastBuildDate>Sat, 17 Sep 2011 02:57:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.2</generator>
		<item>
		<title>Mapping special names to multiple USB serial adapters</title>
		<link>http://blog.digivation.com.au/category/solar/mapping-special-names-to-multiple-usb-serial-adapters</link>
		<comments>http://blog.digivation.com.au/category/solar/mapping-special-names-to-multiple-usb-serial-adapters#comments</comments>
		<pubDate>Fri, 16 Apr 2010 15:34:59 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Solar]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[current cost]]></category>
		<category><![CDATA[currentcost]]></category>
		<category><![CDATA[device driver]]></category>
		<category><![CDATA[envi]]></category>
		<category><![CDATA[gci]]></category>
		<category><![CDATA[mains power monitor]]></category>
		<category><![CDATA[serial]]></category>
		<category><![CDATA[udev]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[watts clever]]></category>

		<guid isPermaLink="false">http://blog.digivation.com.au/?p=125</guid>
		<description><![CDATA[The watts clever envi has a USB serial adapter which is a Prolific pl2303. When inserted it is assigned /dev/ttyUSB0 by udev, among a few other symlinks. I have now obtained an RS485 serial adapter on ebay for A$13.98 delivered which uses the exact same chip, which makes it indistiguishable from the envi&#8217;s port. What [...]]]></description>
			<content:encoded><![CDATA[<p>The watts clever envi has a USB serial adapter which is a Prolific pl2303. When inserted it is assigned /dev/ttyUSB0 by udev, among a few other symlinks. I have now obtained an RS485 serial adapter on ebay for A$13.98 delivered which uses the exact same chip, which makes it indistiguishable from the envi&#8217;s port. What I needed was a way to guarantee uniqueness regardless of the enumeration order on boot or random hot plugin. Naturally, this is for the Aurora GCI which will be installed when they become available in May.</p>
<p>Researching udev a bit, I found /lib/udev/rules.d/60-persistent-serial.rules (mine is a debian system). This file shows how the standard symlinks are done. Since each USB port is unique, I should be able to use that uniqueness to map another symlink to the device.</p>
<p>Firstly plug in the device in the chosen USB port and issue<br />
<code>udevadm info --query=all --name=/dev/ttyUSB1</code></p>
<p>This shows a heap of stuff but mainly we are interested in<br />
<code>P: /devices/pci0000:00/0000:00:1a.0/usb2/2-1/2-1:1.0/ttyUSB1/tty/ttyUSB1</code></p>
<p>Create a file in <code>/etc/udev/rules.d/70-persistent-serial.rules</code> which contains</p>
<blockquote><p>
#see /lib/udev/rules.d/60-persistent-serial.rules</p>
<p>ACTION!=&#8221;add|change&#8221;, GOTO=&#8221;persistent_serial_end&#8221;<br />
SUBSYSTEM!=&#8221;tty&#8221;, GOTO=&#8221;persistent_serial_end&#8221;<br />
KERNEL!=&#8221;ttyUSB[0-9]*|ttyACM[0-9]*&#8221;, GOTO=&#8221;persistent_serial_end&#8221;</p>
<p>IMPORT=&#8221;usb_id &#8211;export %p&#8221;<br />
#IMPORT=&#8221;path_id %p&#8221;</p>
<p>ENV{ID_SERIAL}==&#8221;", GOTO=&#8221;persistent_serial_end&#8221;</p>
<p># usb nearest ethernet connector<br />
ENV{DEVPATH}==&#8221;*usb2/2-2/2-2:1.0*&#8221;, SYMLINK+=&#8221;serial/by-name/envi&#8221;<br />
#bottom front connector<br />
ENV{DEVPATH}==&#8221;*usb7/7-1/7-1:1.0*&#8221;, SYMLINK+=&#8221;serial/by-name/rs485&#8243;<br />
# usb below nearest ethernet connector<br />
ENV{DEVPATH}==&#8221;*usb2/2-1/2-1:1.0*&#8221;, SYMLINK+=&#8221;serial/by-name/rs485&#8243;</p>
<p>LABEL=&#8221;persistent_serial_end&#8221;
</p></blockquote>
<p>Replug and voila you get <code>/dev/serial/by-name/rs485</code> which will always be the correct device.</p>
<p>Now I just have to run the wire to where the GCI will be installed.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.digivation.com.au/category/solar/mapping-special-names-to-multiple-usb-serial-adapters/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

