<?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.read() problem with 0.0.11</title>
		<link>http://forums.leaflabs.com/topic.php?id=832</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:22:29 +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=832" rel="self" type="application/rss+xml" />

		<item>
			<title>poslathian on "serialUSB.read() problem with 0.0.11"</title>
			<link>http://forums.leaflabs.com/topic.php?id=832#post-5766</link>
			<pubDate>Wed, 27 Jul 2011 05:26:25 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">5766@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;oops, i should have posted here a couple of weeks ago - this issue has been resolved&#60;br /&#62;
&#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=894&#38;amp;replies=6#post-5485&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=894&#38;amp;replies=6#post-5485&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "serialUSB.read() problem with 0.0.11"</title>
			<link>http://forums.leaflabs.com/topic.php?id=832#post-5119</link>
			<pubDate>Fri, 10 Jun 2011 14:08:36 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">5119@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Ralf,&#60;br /&#62;
   You should be able to copy the usb code from 0.0.9 into your 0.0.11 install. I will look into the actual bug shortly, but perhaps you could pursue that line as a holdover.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ralfbaecker on "serialUSB.read() problem with 0.0.11"</title>
			<link>http://forums.leaflabs.com/topic.php?id=832#post-5103</link>
			<pubDate>Thu, 09 Jun 2011 16:00:25 +0000</pubDate>
			<dc:creator>ralfbaecker</dc:creator>
			<guid isPermaLink="false">5103@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;thanks. that would be very helpfull.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "serialUSB.read() problem with 0.0.11"</title>
			<link>http://forums.leaflabs.com/topic.php?id=832#post-5066</link>
			<pubDate>Wed, 08 Jun 2011 16:05:50 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">5066@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;The 0.1.0 release is undetermined for now.  The SerialUSB fixes are high-priority, but also involve redoing the entire libmaple USB stack.  In the meantime, I'll try to hack together a workaround for the issue you've been having.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ralfbaecker on "serialUSB.read() problem with 0.0.11"</title>
			<link>http://forums.leaflabs.com/topic.php?id=832#post-5054</link>
			<pubDate>Wed, 08 Jun 2011 06:13:16 +0000</pubDate>
			<dc:creator>ralfbaecker</dc:creator>
			<guid isPermaLink="false">5054@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks mbolivar, when will 0.1.0 be ready for release?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "serialUSB.read() problem with 0.0.11"</title>
			<link>http://forums.leaflabs.com/topic.php?id=832#post-4995</link>
			<pubDate>Mon, 06 Jun 2011 12:44:57 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">4995@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi ralf,&#60;/p&#62;
&#60;p&#62;The SerialUSB behavior is not what we wish it would be.  I'm sorry for the trouble you've been having.  There's a ticket to resolve it open for 0.1.0:&#60;/p&#62;
&#60;p&#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;/p&#62;</description>
		</item>
		<item>
			<title>ralfbaecker on "serialUSB.read() problem with 0.0.11"</title>
			<link>http://forums.leaflabs.com/topic.php?id=832#post-4972</link>
			<pubDate>Sat, 04 Jun 2011 16:24:17 +0000</pubDate>
			<dc:creator>ralfbaecker</dc:creator>
			<guid isPermaLink="false">4972@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Just noticed that there was a post with the same problem 3 month ago:&#60;br /&#62;
&#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=657&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=657&#60;/a&#62;&#60;br /&#62;
Was this bug solved?&#60;br /&#62;
-r
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ralfbaecker on "serialUSB.read() problem with 0.0.11"</title>
			<link>http://forums.leaflabs.com/topic.php?id=832#post-4965</link>
			<pubDate>Sat, 04 Jun 2011 04:43:04 +0000</pubDate>
			<dc:creator>ralfbaecker</dc:creator>
			<guid isPermaLink="false">4965@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks poslathian. For testing I use a little processing sketch.&#60;br /&#62;
This works fine with 0.0.9 but not with 0.0.11.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;myPort.write(char(1)+&#38;quot;&#38;quot;+char(val%255)); // key + value&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;When I send the bytes seperatly it works most of the time. But sometimes I have the same bytes in &#34;key&#34; and &#34;value&#34;. I can avoid that by adding a little delay between the bytes:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;myPort.write(1); // key
delay(1);
myPort.write(val%255); //value&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;the whole sketch looks like:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;import processing.serial.*;

int lf = 10;
String myString = null;
Serial myPort;
int val = 0;        

void setup()
{
  size(200, 200);
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 115200);
}

void draw() {
  while (myPort.available() &#38;gt; 0) {
    myString = myPort.readStringUntil(lf);
    if (myString != null) {
      println(&#38;quot;receive: &#38;quot;+trim(myString));
    }
  }

  myPort.write(char(1)+&#38;quot;&#38;quot;+char(val%255)); // key + value
  val++;
  delay(250);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;EDIT:&#60;br /&#62;
I tested some more staightforward code:&#60;br /&#62;
on maple:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;boolean linebreak = false;
void setup() {
  // nothing
}

void loop() {
  while (SerialUSB.available()) {
    SerialUSB.print(SerialUSB.read());
    linebreak = true;
  }
  if (linebreak) {
    SerialUSB.println();
    linebreak = false;
  }
  delay(100);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;in processing:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;import processing.serial.*;

int lf = 10;
String myString = null;
Serial myPort;
int val = 0;        

void setup()
{
  size(200, 200);
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 115200);
}

void draw() {
  while (myPort.available() &#38;gt; 0) {
    myString = myPort.readStringUntil(lf);
    if (myString != null) {
      println(&#38;quot;receive: &#38;quot;+trim(myString));
    }
  }
  myPort.write(&#38;quot;abc&#38;quot;);
  delay(250);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;the output in 0.0.9 is:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;receive: abc&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;in 0.0.11:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;receive: aaa&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;thanks,&#60;br /&#62;
ralf
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "serialUSB.read() problem with 0.0.11"</title>
			<link>http://forums.leaflabs.com/topic.php?id=832#post-4964</link>
			<pubDate>Fri, 03 Jun 2011 20:45:45 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">4964@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;seems like a bug, looking into it. Odd that it shouldnt work between releases. IIRC serialusb was actually working less in 0.0.9 ... apparently not?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ralfbaecker on "serialUSB.read() problem with 0.0.11"</title>
			<link>http://forums.leaflabs.com/topic.php?id=832#post-4963</link>
			<pubDate>Fri, 03 Jun 2011 19:03:18 +0000</pubDate>
			<dc:creator>ralfbaecker</dc:creator>
			<guid isPermaLink="false">4963@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;hi everybody,&#60;/p&#62;
&#60;p&#62;I just discoverd that some serial code changed its behavior in version 0.0.11.&#60;br /&#62;
I need to read two incoming bytes from the serialUSB device.&#60;/p&#62;
&#60;p&#62;this code works fine with 0.0.9 (win32). I have to turn dtr on to receive the output of the maple on my host.&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;void setup() {
  // nothing
}
void loop() {
  while (SerialUSB.available()&#38;gt;0) {
    uint8 key = SerialUSB.read();
    uint8 value = SerialUSB.read();
    SerialUSB.print(&#38;quot;k &#38;quot;);
    SerialUSB.println(key,DEC);
    SerialUSB.print(&#38;quot;v &#38;quot;);
    SerialUSB.println(value,DEC);
  }
  delay(100);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;With 0.0.11 &#34;value&#34; gets always the same byte like &#34;key&#34; when I send the bytes directly after each other. But when I send the second byte with a little delay (1ms) &#34;value&#34; gets the right byte-value. Is this a bug or am I doing something wrong?&#60;/p&#62;
&#60;p&#62;best,&#60;br /&#62;
ralf
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
