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

		<item>
			<title>poslathian on "readline  (code)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=102#post-612</link>
			<pubDate>Fri, 23 Jul 2010 23:23:45 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">612@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;oooh peek function, good idea. ouch, just missed the 0.0.6, well get it next time!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Feyr on "readline  (code)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=102#post-579</link>
			<pubDate>Mon, 19 Jul 2010 18:24:42 +0000</pubDate>
			<dc:creator>Feyr</dc:creator>
			<guid isPermaLink="false">579@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;if i can suggest, a peek() fonction to the usb code that returns what's in the buffer without removing it could be useful. &#60;/p&#62;
&#60;p&#62;in the meantime, here's a readline function. it's crude but damn useful for debugging. maybe it will save someone digging in libmaple :)&#60;/p&#62;
&#60;p&#62;// todo: make a non-blocking version&#60;/p&#62;
&#60;p&#62;#include &#38;lt;usb_callbacks.h&#38;gt;&#60;/p&#62;
&#60;p&#62;// wait and block for a complete line&#60;br /&#62;
uint32 readline(void* buf, uint32 len) {&#60;/p&#62;
&#60;p&#62;                uint8 avail=SerialUSB.available();&#60;br /&#62;
                uint8 i;&#60;/p&#62;
&#60;p&#62;                if (len &#38;gt; avail) {&#60;br /&#62;
                len= avail;&#60;br /&#62;
                }&#60;/p&#62;
&#60;p&#62;                SerialUSB.println(len);&#60;br /&#62;
                if (avail) {&#60;br /&#62;
                        for (i=0;i&#38;lt;len;i++) {&#60;br /&#62;
                                if (vcomBufferRx[(recvBufOut+i)% VCOM_RX_EPSIZE] == 13) {&#60;/p&#62;
&#60;p&#62;                                        return SerialUSB.read(buf,i+1);&#60;br /&#62;
                                }&#60;br /&#62;
                        }&#60;/p&#62;
&#60;p&#62;                }&#60;/p&#62;
&#60;p&#62;}
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
