<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
<link rel="self" type="application/atom+xml" href="http://forum.robosavvy.com/feed.php?f=5&amp;t=8895" />

<title>RoboSavvy Forum</title>
<subtitle>Robosavvy Forum: The largest online community of Humanoid Robot Builders</subtitle>
<link href="http://forum.robosavvy.com/index.php" />
<updated>2012-11-14T09:20:10+01:00</updated>

<author><name><![CDATA[RoboSavvy Forum]]></name></author>
<id>http://forum.robosavvy.com/feed.php?f=5&amp;t=8895</id>
<entry>
<author><name><![CDATA[xevel]]></name></author>
<updated>2012-11-14T09:20:10+01:00</updated>
<published>2012-11-14T09:20:10+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=8895&amp;p=36534#p36534</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=8895&amp;p=36534#p36534"/>
<title type="html"><![CDATA[Dynamixel SDK with CDC/ACM USB interface (USB2AX)]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=8895&amp;p=36534#p36534"><![CDATA[
Ok, here is the deal: as iBot mentionned, simply commenting the lines with the ioctl, and using directly B1000000 in c_flag does the trick quite well. <br /><br />As suspected, the problems I had with timeout and corruption came from the virtual machine. When I tested with the original code and the USB2Dynamixel, I had the same errors.<br /><br />I changed to a non-virtualized plateform and everything works OK now.<br /><br />For the record, the measured latency for reading data from a servo with the USB2Dynamixel is 1ms (as expected), and the latency of the same code with the USB2AX is around 0.65ms, on my Beagleboard-xM rev A @ 1GHz with Ubuntu Linaro 12.03.<br /><br /><br />Until I get to do things properly (in the documentation of the USB2AX I guess), here is the code I have working with the USB2AX for dxl_hal_open:<br /><dl class="codebox"><dt>Code: </dt><dd><code>int dxl_hal_open&#40;int deviceIndex, float baudrate&#41;<br />&#123;<br />   struct termios newtio;<br />   //struct serial_struct serinfo;<br />   char dev_name&#91;100&#93; = &#123;0, &#125;;<br /><br />   sprintf&#40;dev_name, &quot;/dev/ttyACM%d&quot;, deviceIndex&#41;;<br /><br />   strcpy&#40;gDeviceName, dev_name&#41;;<br />   memset&#40;&amp;newtio, 0, sizeof&#40;newtio&#41;&#41;;<br />   dxl_hal_close&#40;&#41;;<br />   <br />   if&#40;&#40;gSocket_fd = open&#40;gDeviceName, O_RDWR|O_NOCTTY|O_NONBLOCK&#41;&#41; &lt; 0&#41; &#123;<br />      fprintf&#40;stderr, &quot;device open error: %s\n&quot;, dev_name&#41;;<br />      goto DXL_HAL_OPEN_ERROR;<br />   &#125;<br /><br />   newtio.c_cflag      = B1000000|CS8|CLOCAL|CREAD;<br />   newtio.c_iflag      = IGNPAR;<br />   newtio.c_oflag      = 0;<br />   newtio.c_lflag      = 0;<br />   newtio.c_cc&#91;VTIME&#93;   = 0;   // time-out &#44050; &#40;TIME * 0.1&#52488;&#41; 0 : disable<br />   newtio.c_cc&#91;VMIN&#93;   = 0;   // MIN &#51008; read &#44032; return &#46104;&#44592; &#50948;&#54620; &#52572;&#49548; &#47928;&#51088; &#44060;&#49688;<br /><br />   tcflush&#40;gSocket_fd, TCIFLUSH&#41;;<br />   tcsetattr&#40;gSocket_fd, TCSANOW, &amp;newtio&#41;;<br />   <br />   if&#40;gSocket_fd == -1&#41;<br />      return 0;<br />   /*<br />   if&#40;ioctl&#40;gSocket_fd, TIOCGSERIAL, &amp;serinfo&#41; &lt; 0&#41; &#123;<br />      fprintf&#40;stderr, &quot;Cannot get serial info\n&quot;&#41;;<br />      return 0;<br />   &#125;<br />   <br />   serinfo.flags &amp;= ~ASYNC_SPD_MASK;<br />   serinfo.flags |= ASYNC_SPD_CUST;<br />   serinfo.custom_divisor = serinfo.baud_base / baudrate;<br />   <br />   if&#40;ioctl&#40;gSocket_fd, TIOCSSERIAL, &amp;serinfo&#41; &lt; 0&#41; &#123;<br />      fprintf&#40;stderr, &quot;Cannot set serial info\n&quot;&#41;;<br />      return 0;<br />   &#125;*/<br />   <br />   dxl_hal_close&#40;&#41;;<br />   <br />   gfByteTransTime = &#40;float&#41;&#40;&#40;1000.0f / baudrate&#41; * 12.0f&#41;;<br />   <br />   strcpy&#40;gDeviceName, dev_name&#41;;<br />   memset&#40;&amp;newtio, 0, sizeof&#40;newtio&#41;&#41;;<br />   dxl_hal_close&#40;&#41;;<br />   <br />   if&#40;&#40;gSocket_fd = open&#40;gDeviceName, O_RDWR|O_NOCTTY|O_NONBLOCK&#41;&#41; &lt; 0&#41; &#123;<br />      fprintf&#40;stderr, &quot;device open error: %s\n&quot;, dev_name&#41;;<br />      goto DXL_HAL_OPEN_ERROR;<br />   &#125;<br /><br />   newtio.c_cflag      = B1000000|CS8|CLOCAL|CREAD;<br />   newtio.c_iflag      = IGNPAR;<br />   newtio.c_oflag      = 0;<br />   newtio.c_lflag      = 0;<br />   newtio.c_cc&#91;VTIME&#93;   = 0;   // time-out &#44050; &#40;TIME * 0.1&#52488;&#41; 0 : disable<br />   newtio.c_cc&#91;VMIN&#93;   = 0;   // MIN &#51008; read &#44032; return &#46104;&#44592; &#50948;&#54620; &#52572;&#49548; &#47928;&#51088; &#44060;&#49688;<br /><br />   tcflush&#40;gSocket_fd, TCIFLUSH&#41;;<br />   tcsetattr&#40;gSocket_fd, TCSANOW, &amp;newtio&#41;;<br />   <br />   return 1;<br /><br />DXL_HAL_OPEN_ERROR:<br />   dxl_hal_close&#40;&#41;;<br />   return 0;<br />&#125;<br /><br />void dxl_hal_close&#40;&#41;<br />&#123;<br />   if&#40;gSocket_fd != -1&#41;<br />      close&#40;gSocket_fd&#41;;<br />   gSocket_fd = -1;<br />&#125;<br /><br />int dxl_hal_set_baud&#40; float baudrate &#41;<br />&#123;<br />   struct serial_struct serinfo;<br />   <br />   if&#40;gSocket_fd == -1&#41;<br />      return 0;<br />   <br />   if&#40;ioctl&#40;gSocket_fd, TIOCGSERIAL, &amp;serinfo&#41; &lt; 0&#41; &#123;<br />      fprintf&#40;stderr, &quot;Cannot get serial info\n&quot;&#41;;<br />      return 0;<br />   &#125;<br />   <br />   serinfo.flags &amp;= ~ASYNC_SPD_MASK;<br />   serinfo.flags |= ASYNC_SPD_CUST;<br />   serinfo.custom_divisor = serinfo.baud_base / baudrate;<br />   <br />   if&#40;ioctl&#40;gSocket_fd, TIOCSSERIAL, &amp;serinfo&#41; &lt; 0&#41; &#123;<br />      fprintf&#40;stderr, &quot;Cannot set serial info\n&quot;&#41;;<br />      return 0;<br />   &#125;<br />   <br />   //dxl_hal_close&#40;&#41;;<br />   //dxl_hal_open&#40;gDeviceName, baudrate&#41;;<br />   <br />   gfByteTransTime = &#40;float&#41;&#40;&#40;1000.0f / baudrate&#41; * 12.0f&#41;;<br />   return 1;<br />&#125;</code></dd></dl><p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=2658">xevel</a> — Wed Nov 14, 2012 9:20 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[i-Bot]]></name></author>
<updated>2012-11-13T12:46:43+01:00</updated>
<published>2012-11-13T12:46:43+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=8895&amp;p=36520#p36520</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=8895&amp;p=36520#p36520"/>
<title type="html"><![CDATA[Dynamixel SDK with CDC/ACM USB interface (USB2AX)]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=8895&amp;p=36520#p36520"><![CDATA[
If there are collisions on the bus it implies you are sending a new packet before you have received reply <br />Are you sure your txrxpacket() are not timing out ? I think the timeout is usually about 5ms in the Robotis dynamixel code. If you are using a virtual machine the delay through kernel may be longer than that.<br />I have it running OK with USB2AX on laptop(Ubuntu 12.04), MK-802(lubuntu 12.04), and RPi(Raspbian). My USB2AX firmware is your latest with the bulk_read and the CM730 emulation added.<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=159">i-Bot</a> — Tue Nov 13, 2012 12:46 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[xevel]]></name></author>
<updated>2012-11-13T12:24:36+01:00</updated>
<published>2012-11-13T12:24:36+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=8895&amp;p=36519#p36519</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=8895&amp;p=36519#p36519"/>
<title type="html"><![CDATA[Dynamixel SDK with CDC/ACM USB interface (USB2AX)]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=8895&amp;p=36519#p36519"><![CDATA[
Indeed, that's what I did with newtio.c_flag, but that's where I get all the errors.<br /><br />The available baud rates used in c_flag I took from here: <!-- m --><a class="postlink" href="http://linux.die.net/include/bits/termios.h">http://linux.die.net/include/bits/termios.h</a><!-- m --><br /><br />I did my tests on a Lubuntu 12.10 in a VMware Player virtual machine, and what actually happens on the Dynamixel bus is that there are collisions between the output and input packets, that obviously result  in a very confused Dynamixel SDK.<br />My first thought were that the timing (based on gettimeofday() ) was not working properly [there have been report of the system clock jumping around on VMs], but I had someone run it on his physical machine with a Lubuntu 12.04 with the same result.<br /><br />In all honesty, I haven't done all the testing I should have (I should test with the USB2Dynamixel to rule out the timing problem, and do it on a real machine...), and I was just checking if anybody had had the same problem before diving deeper. <br />I would be glad to have your code so that I have a reference to compare to to debug my setup.<br /><br />Thanks i-Bot <img src="http://forum.robosavvy.com/images/smilies/icon_smile.gif" alt=":)" title="Smile" /><p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=2658">xevel</a> — Tue Nov 13, 2012 12:24 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[i-Bot]]></name></author>
<updated>2012-11-13T12:07:53+01:00</updated>
<published>2012-11-13T12:07:53+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=8895&amp;p=36518#p36518</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=8895&amp;p=36518#p36518"/>
<title type="html"><![CDATA[Dynamixel SDK with CDC/ACM USB interface (USB2AX)]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=8895&amp;p=36518#p36518"><![CDATA[
I don't use the Dynamixel SDK, but the hal code is the basis of the DARwin code, so it had the same issue.<br /><br />As you correctly noticed, the setting of the not standard baud rate is specific to the FTDI USB to serial and does not work with the CDC_ACM driver. The good news is that the later drivers for CDC-ACM do understand higher baud rate values. So you can use <br />newtio.c_cflag = B1000000|CS8|CLOCAL|CREAD;<br />instead of:<br />newtio.c_cflag = B38400|CS8|CLOCAL|CREAD;<br />And then drop all the stuff related to setting the setting the serial structure through ioctl.<br /><br />I always set up to 1000000bps so don't use the routine to change the baudrate, so never fixed that. If you do this, then you note the driver only accepts a limietd range of baud rates, and you will need to check for this. Note also that (B1000000 is #define as a value other than 1000000).<br /><br />Let me know if you have any more problem and I will send the DARwin code which works with USB2AX.<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=159">i-Bot</a> — Tue Nov 13, 2012 12:07 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[xevel]]></name></author>
<updated>2012-11-13T00:04:03+01:00</updated>
<published>2012-11-13T00:04:03+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=8895&amp;p=36514#p36514</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=8895&amp;p=36514#p36514"/>
<title type="html"><![CDATA[Dynamixel SDK with CDC/ACM USB interface (USB2AX)]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=8895&amp;p=36514#p36514"><![CDATA[
Just a further check (I search around) before I dive deeper into it myself: has anyone made the Dynamixel SDK work reliably with a CDC/ACM USB interface (like the USB2AX, or a Minimus or even an UNO...)?<br /><br />The first error I get is with the line that applies the non-standard baudrate:<br /><dl class="codebox"><dt>Code: </dt><dd><code>if&#40;ioctl&#40;gSocket_fd, TIOCSSERIAL, &amp;serinfo&#41; &lt; 0&#41; &#123;</code></dd></dl><br /><br />I removed it (since it seems that<a href="http://thread.gmane.org/gmane.linux.usb.general/59199/focus=59278" class="postlink">it does not have any sense for the CDC/ACM driver</a>) and directly set the right baudrate in the termios structure, but then I get errors (timeout and corruption) nearly every packet of the example ReadWrite.<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=2658">xevel</a> — Tue Nov 13, 2012 12:04 am</p><hr />
]]></content>
</entry>
</feed>