<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: SerialUSB locking up after long string</title>
		<link>http://forums.leaflabs.com/topic.php?id=724</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:16:25 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=724" rel="self" type="application/rss+xml" />

		<item>
			<title>StephenFromNYC on "SerialUSB locking up after long string"</title>
			<link>http://forums.leaflabs.com/topic.php?id=724&amp;page=2#post-4320</link>
			<pubDate>Wed, 13 Apr 2011 13:55:02 +0000</pubDate>
			<dc:creator>StephenFromNYC</dc:creator>
			<guid isPermaLink="false">4320@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;CidVilas-&#60;/p&#62;
&#60;p&#62;In my previous responses (from the first page) I incorrectly suggested using the &#60;code&#62;SerialUSB.print(buffer, buffersize)&#60;/code&#62; function.&#60;/p&#62;
&#60;p&#62;The correct function's name is &#60;code&#62;SerialUSB.write(buffer, buffersize)&#60;/code&#62;.&#60;/p&#62;
&#60;p&#62;I corrected the mistakes on page 1 of this topic.&#60;/p&#62;
&#60;p&#62;Hope the &#60;code&#62;SerialUSB.write()&#60;/code&#62; function helps in your project.&#60;/p&#62;
&#60;p&#62;Sorry for the initial confusing information.&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://forums.leaflabs.com/profile.php?id=843&#34;&#62;Stephen from NYC&#60;/a&#62; (full disclosure: I am not a member of the LeafLabs staff)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "SerialUSB locking up after long string"</title>
			<link>http://forums.leaflabs.com/topic.php?id=724&amp;page=2#post-4318</link>
			<pubDate>Wed, 13 Apr 2011 13:29:58 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">4318@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;CidVilas,&#60;/p&#62;
&#60;p&#62;I've reopened our old SerialUSB bug.  It's too late in the release cycle for a fix to make it into Maple IDE 0.0.10, but this bug blocks the release of 0.1.0.  &#60;/p&#62;
&#60;p&#62;References:&#60;br /&#62;
&#60;a href=&#34;http://code.google.com/p/leaflabs/issues/detail?id=10&#34; rel=&#34;nofollow&#34;&#62;http://code.google.com/p/leaflabs/issues/detail?id=10&#60;/a&#62;&#60;br /&#62;
&#60;a href=&#34;http://wiki.leaflabs.com/index.php?title=Blocking_Changes&#34; rel=&#34;nofollow&#34;&#62;http://wiki.leaflabs.com/index.php?title=Blocking_Changes&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "SerialUSB locking up after long string"</title>
			<link>http://forums.leaflabs.com/topic.php?id=724#post-4305</link>
			<pubDate>Wed, 13 Apr 2011 07:28:25 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">4305@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;&#60;a href=&#34;http://en.wikipedia.org/wiki/G-code&#34;&#62;G-code&#60;/a&#62; is a data interface format used to drive CNC machines.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>StephenFromNYC on "SerialUSB locking up after long string"</title>
			<link>http://forums.leaflabs.com/topic.php?id=724#post-4290</link>
			<pubDate>Tue, 12 Apr 2011 15:10:24 +0000</pubDate>
			<dc:creator>StephenFromNYC</dc:creator>
			<guid isPermaLink="false">4290@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hello CidVilas-&#60;/p&#62;
&#60;p&#62;I think adding a 3D printer to the list of Maple projects would be cool.  If you can describe what you need at the host and device ends perhaps other users can help you with the coding.  Remember, you are the &#34;Tonokips Reprap&#34; expert.  What is GCode?  All we understand is the Maple.  Some users are also Arduino experts.&#60;/p&#62;
&#60;p&#62;Besides the test code which you have shared what else have you tried and what works?&#60;/p&#62;
&#60;p&#62;For example, what characters are received/sent by the host system, what type of calculations are performed by the Maple board, and what type of other hardware (eg. motors, sensors, heaters, fans) are controlled by the Maple board?&#60;/p&#62;
&#60;p&#62;At a more basic level, why are you trying to switch to a different microcontroller board?  Is there something the Maple can do which the Arduino will not accomplish?&#60;/p&#62;
&#60;p&#62;Here is a discussion of USB concepts: &#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=692&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=692&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Not everything I say in the USB discussion is correct, so be critical of what you read.  However, the one important USB concept which you should focus on is the &#34;data packet&#34;.&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://forums.leaflabs.com/profile.php?id=843&#34;&#62;Stephen from NYC&#60;/a&#62; (full disclosure: I am not a member of the LeafLabs staff)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>CidVilas on "SerialUSB locking up after long string"</title>
			<link>http://forums.leaflabs.com/topic.php?id=724#post-4285</link>
			<pubDate>Tue, 12 Apr 2011 09:23:36 +0000</pubDate>
			<dc:creator>CidVilas</dc:creator>
			<guid isPermaLink="false">4285@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;In the serial terminal in MapleIDE I type '1234567890' at a time and I type '*' to clear and create a new line.&#60;br /&#62;
1234567890123456789012345678901234567890&#60;br /&#62;
the above line sent to the device will lock it up, while&#60;br /&#62;
123456789012345678901234567890&#60;br /&#62;
Will not lock up and echo back after plenty of sends.&#60;/p&#62;
&#60;p&#62;I hope that makes sense. I don't really understand the low level application. And I can't design the application around the device. I want to design the device around the application so having to recombine strings on the host side wouldn't work for me unfortunately. :)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>StephenFromNYC on "SerialUSB locking up after long string"</title>
			<link>http://forums.leaflabs.com/topic.php?id=724#post-4284</link>
			<pubDate>Tue, 12 Apr 2011 08:38:31 +0000</pubDate>
			<dc:creator>StephenFromNYC</dc:creator>
			<guid isPermaLink="false">4284@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hello-&#60;/p&#62;
&#60;p&#62;CidVilas,  I am glad you found the February 2011 Mac OS dmg SNAPshot (not screenshot) file.  I prefer the current naming convention, because the complete version number is visible (for all supported OS).&#60;/p&#62;
&#60;p&#62;I do not know which browser you use with Mac OS, but Firefox shows the name of the file in the lower left hand corner of the browser window when the cursors passes over a hyperlink.  If you see a web page with two or three files with the same software &#34;version&#34;, just use the mouseover trick to see which file applies to your system.&#60;/p&#62;
&#60;p&#62;A few observations:&#60;/p&#62;
&#60;p&#62;The February 13 snapshot has a bug in &#60;code&#62;SerialUSB.read()&#60;/code&#62; which occurs if you are reading more than one character (which you are *not* doing in your sample code).&#60;/p&#62;
&#60;p&#62;If I am counting correctly &#60;code&#62;SerialUSB.print(&#38;quot;\n Break \n&#38;quot;);&#60;/code&#62; sends 9 characters at a time and not ten.  Are you counting &#60;code&#62;SerialUSB.print(character);&#60;/code&#62; as the tenth character?&#60;/p&#62;
&#60;p&#62;As I mentioned above &#60;code&#62;SerialUSB.write(buffer, length)&#60;/code&#62; seems to work reliably for me (using a Windows system) for sending large amounts of data.&#60;/p&#62;
&#60;p&#62;See the questions and code described in this topic (go to the second page):&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=639&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=639&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;If all your characters are 8-bit characters you will not have to worry about bit-shifting (in the example, gbulmer's code was a solution to sending 12-bit values).&#60;/p&#62;
&#60;p&#62;I still have not had the time to test the low level USB API described above by poslathian.  If you get to it before I do please post your results.&#60;/p&#62;
&#60;p&#62;Thanks!&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://forums.leaflabs.com/profile.php?id=843&#34;&#62;Stephen from NYC&#60;/a&#62; (full disclosure: I am not a member of the LeafLabs staff)&#60;/p&#62;
&#60;p&#62;[my current &#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=690#post-3949&#34;&#62;development system&#60;/a&#62; (old, but still working)]
&#60;/p&#62;</description>
		</item>
		<item>
			<title>CidVilas on "SerialUSB locking up after long string"</title>
			<link>http://forums.leaflabs.com/topic.php?id=724#post-4281</link>
			<pubDate>Mon, 11 Apr 2011 21:16:10 +0000</pubDate>
			<dc:creator>CidVilas</dc:creator>
			<guid isPermaLink="false">4281@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;This is what im using:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;char character = &#38;#39; &#38;#39;;

void setup() {
  pinMode(13, OUTPUT);
}

void loop() {
  delay(10);
 while(1) {
 if(SerialUSB.available()) {
   digitalWrite(13, HIGH);
   character = SerialUSB.read();
   if(character == &#38;#39;*&#38;#39;) SerialUSB.print(&#38;quot;\n Break \n&#38;quot;);
   SerialUSB.print(character);
 } else {
   digitalWrite(13, LOW);
 }
 }
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>mbolivar on "SerialUSB locking up after long string"</title>
			<link>http://forums.leaflabs.com/topic.php?id=724#post-4280</link>
			<pubDate>Mon, 11 Apr 2011 19:29:54 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">4280@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Sample code, please?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>CidVilas on "SerialUSB locking up after long string"</title>
			<link>http://forums.leaflabs.com/topic.php?id=724#post-4279</link>
			<pubDate>Mon, 11 Apr 2011 18:55:47 +0000</pubDate>
			<dc:creator>CidVilas</dc:creator>
			<guid isPermaLink="false">4279@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;The Screenshot 2-13-2011 did not solve the problem.  I can send, in 10 character increments, from 0 to 50 characters without problem.  After sending 70 characters it locked up.  Sometimes it locks up at 50 characters too.&#60;br /&#62;
Still unsure why.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>CidVilas on "SerialUSB locking up after long string"</title>
			<link>http://forums.leaflabs.com/topic.php?id=724#post-4278</link>
			<pubDate>Mon, 11 Apr 2011 18:33:01 +0000</pubDate>
			<dc:creator>CidVilas</dc:creator>
			<guid isPermaLink="false">4278@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Oh!  I see it now.  The extensions of the Snapshots are cut off so i could not see that there was a Mac version there.  Thank you. :)  Maybe put the Mac label at the beginning so it doesnt get cut off. Ill try again and post later.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>StephenFromNYC on "SerialUSB locking up after long string"</title>
			<link>http://forums.leaflabs.com/topic.php?id=724#post-4269</link>
			<pubDate>Mon, 11 Apr 2011 10:41:24 +0000</pubDate>
			<dc:creator>StephenFromNYC</dc:creator>
			<guid isPermaLink="false">4269@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hello-&#60;/p&#62;
&#60;p&#62;CidVilas, check the snapshot directory (listed above) again.  The February 2011 IDE snapshots with the improved &#60;code&#62;Serial.USB&#60;/code&#62; functions include:&#60;/p&#62;
&#60;p&#62;1) linux (32-bit); a tgz file&#60;br /&#62;
2) mac os (10.6); a dmg file&#60;br /&#62;
3) win (xp); a zip file&#60;/p&#62;
&#60;p&#62;I am not giving you the direct link to the compressed 32-bit Mac OS X file, because I want these instructions to be as useful to as many users as possible.&#60;/p&#62;
&#60;p&#62;I have not tried the low level USB API functions suggested by poslathian. (EDIT: I fixed the link above in poslathian's hyperlink so it does not include the closing parenthesis).&#60;/p&#62;
&#60;p&#62;However, the &#60;code&#62;SerialUSB.write(buffer, length)&#60;/code&#62; function works well, especially when the length is 64 (the size of the USB buffer).  The &#60;code&#62;SerialUSB.print(char)&#60;/code&#62; function may not send the character until the &#34;timeout&#34; value is exceeded.&#60;/p&#62;
&#60;p&#62;For speedy USB transmissions one strategy is to divide your long string using a 64 byte buffer sending the entire buffer with a single &#60;code&#62;SerialUSB.write(buffer_buffer_64_char, 64)&#60;/code&#62; command.&#60;/p&#62;
&#60;p&#62;Let us know how things work!&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://forums.leaflabs.com/profile.php?id=843&#34;&#62;Stephen from NYC&#60;/a&#62; (full disclosure: I am not a member of the LeafLabs staff)&#60;/p&#62;
&#60;p&#62;[my current &#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=690#post-3949&#34;&#62;development system&#60;/a&#62; (old, but still working)]
&#60;/p&#62;</description>
		</item>
		<item>
			<title>CidVilas on "SerialUSB locking up after long string"</title>
			<link>http://forums.leaflabs.com/topic.php?id=724#post-4254</link>
			<pubDate>Sat, 09 Apr 2011 03:13:10 +0000</pubDate>
			<dc:creator>CidVilas</dc:creator>
			<guid isPermaLink="false">4254@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I see that the latest snapshots are only for windows.  Any plans for Mac OSX snapshots?&#60;/p&#62;
&#60;p&#62;I cant figure out exactly how the usb.h would work.  Am i still going to have to perform some specific work host side?  Or will it be seamless for the host and the client (Maple) be the only change?&#60;/p&#62;
&#60;p&#62;Thank you!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "SerialUSB locking up after long string"</title>
			<link>http://forums.leaflabs.com/topic.php?id=724#post-4244</link>
			<pubDate>Fri, 08 Apr 2011 17:08:36 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">4244@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;StephenFromNYC, thanks for filling in for me on the usb issue! CidVilas, please do use the snapshot releases, as they come with improvements to the SerialUSB. We have been doing our best to improve it with each release, and the last snapshot had a rather major patch to serialusb installed. I also recommend, for when you are scuttling large amounts of data through the usb, you try and use the low level usb api (see &#60;a href=&#34;https://github.com/leaflabs/libmaple/blob/master/libmaple/usb/usb.h&#34;&#62;https://github.com/leaflabs/libmaple/blob/master/libmaple/usb/usb.h&#60;/a&#62;) which requires a working knowledge of pointers but works much more quickly than SerialUSB and has the ability to actually send multiple bytes in a single packet. &#60;/p&#62;
&#60;p&#62;add &#34;usb.h&#34; to the top of your sketch and use:&#60;br /&#62;
uint32 usbSendBytes(uint8* sendBuf,uint32 len);&#60;br /&#62;
uint32 usbBytesAvailable(void);&#60;br /&#62;
uint32 usbReceiveBytes(uint8* recvBuf, uint32 len);&#60;/p&#62;
&#60;p&#62;sendBytes will return the number of bytes sent, which may be less than the number you intended! (so check the return value and try again!). receiveBytes will return the number of bytes received, which may be less than the number of bytes you asked for (so again, check the return value and try again!). These functions are asynchronous, simple in implementation, and worth the extra complexity when working with large strings. &#60;/p&#62;
&#60;p&#62;If anyone finds bugs in the serialusb, please do post with as much detail as possible! The snapshots improvements will obviously be baked into the next major release
&#60;/p&#62;</description>
		</item>
		<item>
			<title>CidVilas on "SerialUSB locking up after long string"</title>
			<link>http://forums.leaflabs.com/topic.php?id=724#post-4222</link>
			<pubDate>Thu, 07 Apr 2011 16:58:32 +0000</pubDate>
			<dc:creator>CidVilas</dc:creator>
			<guid isPermaLink="false">4222@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Tonokips is just one of the many arduino firmware flavors available for reprap systems. Tonokips is typically used with arduino mega and a RAMPS board. The software used on the PC side with Tonokip is RepSnapper.&#60;br /&#62;
No worries about the questions! I'm sure I'll be asking plenty more of them as the project goes on ;)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>StephenFromNYC on "SerialUSB locking up after long string"</title>
			<link>http://forums.leaflabs.com/topic.php?id=724#post-4219</link>
			<pubDate>Thu, 07 Apr 2011 16:42:57 +0000</pubDate>
			<dc:creator>StephenFromNYC</dc:creator>
			<guid isPermaLink="false">4219@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hello-&#60;/p&#62;
&#60;p&#62;CidVilas, I am familiar with RepRaps and 3D lithography, but what is &#34;Tonokips Firmware&#34;?&#60;/p&#62;
&#60;p&#62;Sorry for all the questions.&#60;/p&#62;
&#60;p&#62;Thanks!&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://forums.leaflabs.com/profile.php?id=843&#34;&#62;Stephen from NYC&#60;/a&#62; (full disclosure: I am not a member of the LeafLabs staff)
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
