<?xml version="1.0" encoding="UTF-8"?><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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: talking usb-serial to my arduino from lisp (sbcl) on linux</title>
	<atom:link href="http://ryepup.unwashedmeme.com/blog/2009/09/28/talking-usb-serial-to-my-arduino-from-lisp-sbcl-on-linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://ryepup.unwashedmeme.com/blog/2009/09/28/talking-usb-serial-to-my-arduino-from-lisp-sbcl-on-linux/</link>
	<description>mostly tech, mostly rants</description>
	<lastBuildDate>Tue, 07 Feb 2012 18:44:56 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Monteagle Lodging</title>
		<link>http://ryepup.unwashedmeme.com/blog/2009/09/28/talking-usb-serial-to-my-arduino-from-lisp-sbcl-on-linux/comment-page-1/#comment-75341</link>
		<dc:creator>Monteagle Lodging</dc:creator>
		<pubDate>Sat, 14 Jan 2012 02:19:22 +0000</pubDate>
		<guid isPermaLink="false">http://ryepup.unwashedmeme.com/blog/?p=131#comment-75341</guid>
		<description>You could definitely see your expertise within the work you write. The world hopes for even more passionate writers such as you who aren&#039;t afraid to say how they believe. Always go after your heart. &quot;In order to preserve your self-respect, it is sometimes necessary to lie and cheat.&quot; by Robert Byrne.</description>
		<content:encoded><![CDATA[<p>You could definitely see your expertise within the work you write. The world hopes for even more passionate writers such as you who aren&#8217;t afraid to say how they believe. Always go after your heart. &#8220;In order to preserve your self-respect, it is sometimes necessary to lie and cheat.&#8221; by Robert Byrne.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: markus</title>
		<link>http://ryepup.unwashedmeme.com/blog/2009/09/28/talking-usb-serial-to-my-arduino-from-lisp-sbcl-on-linux/comment-page-1/#comment-74535</link>
		<dc:creator>markus</dc:creator>
		<pubDate>Tue, 03 Jan 2012 23:41:33 +0000</pubDate>
		<guid isPermaLink="false">http://ryepup.unwashedmeme.com/blog/?p=131#comment-74535</guid>
		<description>Audio started playing as soon as I opened up this site, so irritating!</description>
		<content:encoded><![CDATA[<p>Audio started playing as soon as I opened up this site, so irritating!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BBq Fir Pit</title>
		<link>http://ryepup.unwashedmeme.com/blog/2009/09/28/talking-usb-serial-to-my-arduino-from-lisp-sbcl-on-linux/comment-page-1/#comment-71047</link>
		<dc:creator>BBq Fir Pit</dc:creator>
		<pubDate>Mon, 14 Nov 2011 01:49:21 +0000</pubDate>
		<guid isPermaLink="false">http://ryepup.unwashedmeme.com/blog/?p=131#comment-71047</guid>
		<description>It’s actually a nice and helpful piece of info. I am glad that you shared this helpful info with us. Please keep us up to date like this. Thanks for sharing.</description>
		<content:encoded><![CDATA[<p>It’s actually a nice and helpful piece of info. I am glad that you shared this helpful info with us. Please keep us up to date like this. Thanks for sharing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ryan</title>
		<link>http://ryepup.unwashedmeme.com/blog/2009/09/28/talking-usb-serial-to-my-arduino-from-lisp-sbcl-on-linux/comment-page-1/#comment-32517</link>
		<dc:creator>ryan</dc:creator>
		<pubDate>Mon, 05 Oct 2009 22:08:51 +0000</pubDate>
		<guid isPermaLink="false">http://ryepup.unwashedmeme.com/blog/?p=131#comment-32517</guid>
		<description>I didn&#039;t find time for it this weekend, but I definetly plan to revisit this.  You folks are awesome for volunteering all this code.

@fortunatus: I had thought about that a lot, I think I&#039;m going to start with a very simple pass-through interface, where lisp asks for the value of a pin, or sets the value of a pin, etc.  I&#039;m basically going to make a big switch statement on the arduino and pass serial input in.

I had considered jumping down several rabbit holes:
 1. making an interpreter to run on the arduino, with a big array to store the program, then a way to re-program it from lisp, essentially recreating my current C/avr-gcc/avrdude toolchain in lisp and C
 1. making a DSL in lisp that compiles down to C/C++, then use the standard toolchain from there

I&#039;d be surprised if I made it down any of those holes, they seem like more work than I&#039;m usually willing to give my hobby projects.</description>
		<content:encoded><![CDATA[<p>I didn&#8217;t find time for it this weekend, but I definetly plan to revisit this.  You folks are awesome for volunteering all this code.</p>
<p>@fortunatus: I had thought about that a lot, I think I&#8217;m going to start with a very simple pass-through interface, where lisp asks for the value of a pin, or sets the value of a pin, etc.  I&#8217;m basically going to make a big switch statement on the arduino and pass serial input in.</p>
<p>I had considered jumping down several rabbit holes:<br />
 1. making an interpreter to run on the arduino, with a big array to store the program, then a way to re-program it from lisp, essentially recreating my current C/avr-gcc/avrdude toolchain in lisp and C<br />
 1. making a DSL in lisp that compiles down to C/C++, then use the standard toolchain from there</p>
<p>I&#8217;d be surprised if I made it down any of those holes, they seem like more work than I&#8217;m usually willing to give my hobby projects.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fortunatus</title>
		<link>http://ryepup.unwashedmeme.com/blog/2009/09/28/talking-usb-serial-to-my-arduino-from-lisp-sbcl-on-linux/comment-page-1/#comment-32381</link>
		<dc:creator>fortunatus</dc:creator>
		<pubDate>Wed, 30 Sep 2009 21:34:54 +0000</pubDate>
		<guid isPermaLink="false">http://ryepup.unwashedmeme.com/blog/?p=131#comment-32381</guid>
		<description>So you will use the Arduino for a serial-to-I/O interface, which is a great architecture for leaving the smarts on the PC running Lisp.  I&#039;ve done lots of factory automation with that approach.

But you are still left programming the Arduino with the C/C++.  And, if you want the Arduino to exercise application smarts - for either embedding stand alone, or for offloading the PC - you still must program those in the C/C++.

So the question is whether to go further into breaking away from that environment.  Write a Lisp system to download executable image (called a vector) from PC to Arduino.  Then use Lisp to implement a DSL for coding the application logic.  Lisp would create the executable vector from the DSL input.

The DSL could be a collection of functions that generate the vector as they are called.

Or, like the FORTH guy did, write a small as possible interpreter running on the Arduino for the DSL, which in his case was FORTH.  Or a byte-code interpreter could run on the Arduino, etc, etc.</description>
		<content:encoded><![CDATA[<p>So you will use the Arduino for a serial-to-I/O interface, which is a great architecture for leaving the smarts on the PC running Lisp.  I&#8217;ve done lots of factory automation with that approach.</p>
<p>But you are still left programming the Arduino with the C/C++.  And, if you want the Arduino to exercise application smarts &#8211; for either embedding stand alone, or for offloading the PC &#8211; you still must program those in the C/C++.</p>
<p>So the question is whether to go further into breaking away from that environment.  Write a Lisp system to download executable image (called a vector) from PC to Arduino.  Then use Lisp to implement a DSL for coding the application logic.  Lisp would create the executable vector from the DSL input.</p>
<p>The DSL could be a collection of functions that generate the vector as they are called.</p>
<p>Or, like the FORTH guy did, write a small as possible interpreter running on the Arduino for the DSL, which in his case was FORTH.  Or a byte-code interpreter could run on the Arduino, etc, etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: marsijanin</title>
		<link>http://ryepup.unwashedmeme.com/blog/2009/09/28/talking-usb-serial-to-my-arduino-from-lisp-sbcl-on-linux/comment-page-1/#comment-32372</link>
		<dc:creator>marsijanin</dc:creator>
		<pubDate>Wed, 30 Sep 2009 15:23:17 +0000</pubDate>
		<guid isPermaLink="false">http://ryepup.unwashedmeme.com/blog/?p=131#comment-32372</guid>
		<description>I&#039;m using with-* licke macro for RS-422/485/232 devices
http://paste.lisp.org/display/87952</description>
		<content:encoded><![CDATA[<p>I&#8217;m using with-* licke macro for RS-422/485/232 devices<br />
<a href="http://paste.lisp.org/display/87952" rel="nofollow">http://paste.lisp.org/display/87952</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elkin Botero (cybux) 's status on Wednesday, 30-Sep-09 12:41:50 UTC - Identi.ca</title>
		<link>http://ryepup.unwashedmeme.com/blog/2009/09/28/talking-usb-serial-to-my-arduino-from-lisp-sbcl-on-linux/comment-page-1/#comment-32363</link>
		<dc:creator>Elkin Botero (cybux) 's status on Wednesday, 30-Sep-09 12:41:50 UTC - Identi.ca</dc:creator>
		<pubDate>Wed, 30 Sep 2009 12:42:03 +0000</pubDate>
		<guid isPermaLink="false">http://ryepup.unwashedmeme.com/blog/?p=131#comment-32363</guid>
		<description>[...]  http://ryepup.unwashedmeme.com/blog/2009/09/28/talking-usb-serial-to-my-arduino-from-lisp-sbcl-on-l...       a few seconds ago  from  choqoK [...]</description>
		<content:encoded><![CDATA[<p>[...]  <a href="http://ryepup.unwashedmeme.com/blog/2009/09/28/talking-usb-serial-to-my-arduino-from-lisp-sbcl-on-l.." rel="nofollow">http://ryepup.unwashedmeme.com/blog/2009/09/28/talking-usb-serial-to-my-arduino-from-lisp-sbcl-on-l..</a>.       a few seconds ago  from  choqoK [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2009-09-29 &#171; Blarney Fellow</title>
		<link>http://ryepup.unwashedmeme.com/blog/2009/09/28/talking-usb-serial-to-my-arduino-from-lisp-sbcl-on-linux/comment-page-1/#comment-32345</link>
		<dc:creator>links for 2009-09-29 &#171; Blarney Fellow</dc:creator>
		<pubDate>Wed, 30 Sep 2009 01:14:02 +0000</pubDate>
		<guid isPermaLink="false">http://ryepup.unwashedmeme.com/blog/?p=131#comment-32345</guid>
		<description>[...] Ryan’s Tech Blog » talking usb-serial to my arduino from lisp (sbcl) on linux (tags: lisp hardware linux arduino) [...]</description>
		<content:encoded><![CDATA[<p>[...] Ryan’s Tech Blog » talking usb-serial to my arduino from lisp (sbcl) on linux (tags: lisp hardware linux arduino) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Raison</title>
		<link>http://ryepup.unwashedmeme.com/blog/2009/09/28/talking-usb-serial-to-my-arduino-from-lisp-sbcl-on-linux/comment-page-1/#comment-32331</link>
		<dc:creator>Kevin Raison</dc:creator>
		<pubDate>Tue, 29 Sep 2009 15:59:44 +0000</pubDate>
		<guid isPermaLink="false">http://ryepup.unwashedmeme.com/blog/?p=131#comment-32331</guid>
		<description>I use the following code in SBCL to speak to bar code scanners.  Perhaps it would be helpful to you?

(defun get-posix-baud (baud)
  (when (stringp baud)
    (setf baud (parse-integer baud)))
  (case baud
    (110       sb-posix:b110)
    (300       sb-posix:b300)
    (1200      sb-posix:b1200)
    (2400      sb-posix:b2400)
    (4800      sb-posix:b4800)
    (9600      sb-posix:b9600)
    (19200     sb-posix:b19200)
    (38400     sb-posix:b38400)
    (57600     sb-posix:b57600)
    (115200    sb-posix:b115200)
    (230400    sb-posix:b230400)
    (otherwise sb-posix:b19200)))

(defun open-serial (tty &amp;optional (baud 9600))
  (handler-case
      (let* ((fd (sb-posix:open
      tty
      (boole boole-ior
       (boole boole-ior sb-posix:O-RDWR sb-posix:O-NOCTTY)
       sb-posix:O-NDELAY)))
       (options (sb-posix:tcgetattr fd))
       (serial-stream nil)
       (posix-baud (get-posix-baud baud)))
  (sb-posix:cfsetispeed posix-baud options)
  (sb-posix:cfsetospeed posix-baud options)
  (setf (sb-posix:termios-cflag options)
        (boole boole-ior sb-posix:CLOCAL sb-posix:CREAD))
  (setf (sb-posix:termios-cflag options)
        (boole boole-and
         (sb-posix:termios-cflag options) (boole boole-c1 sb-posix:PARENB 0)))
  (setf (sb-posix:termios-cflag options)
        (boole boole-and
         (sb-posix:termios-cflag options) (boole boole-c1 sb-posix:CSTOPB 0)))
  (setf (sb-posix:termios-cflag options)
        (boole boole-and
         (sb-posix:termios-cflag options) (boole boole-c1 sb-posix:CSIZE 0)))
  (setf (sb-posix:termios-cflag options)
        (boole boole-ior (sb-posix:termios-cflag options) sb-posix:CS8))
  (sb-posix:tcsetattr fd sb-posix:TCSANOW options)
  (setf serial-stream
        (sb-sys:make-fd-stream fd :input t :output t :element-type &#039;unsigned-byte :buffering :full))
  (values serial-stream fd))
    (error (condition)
      (format t &quot;Problem opening serial port ~A: ~A&quot; tty condition))))

(defun close-serial (fd)
  (sb-posix:fcntl fd sb-posix:F-SETFL 0)
  (sb-posix:close fd))

(let ((bcode nil))
  (defun data-received-handler (stream)
    (logger :info &quot;DATA-RECEIVED-HANDLER called on ~A&quot; stream)
    (handler-case
  (let ((c nil))
    (loop
       (setf c (read-byte stream))
       (logger :info &quot;SERIAL GOT: ~A / ~A&quot; c (code-char c))
       (cond ((eql c 13)
        (logger :info &quot;ENQUEUEING ~A&quot; (reverse bcode))
        (sb-queue:enqueue (format nil &quot;~{~a~}&quot; (reverse bcode)) *barcode-reader-queue*)
        (setf bcode nil))
       ((eql c 10)  (return))
       ((eql c 2)   (setf bcode nil))
       (t           (push (code-char c) bcode)))))
      (end-of-file (condition)
  (declare (ignore condition)))
      (error (condition)
  (logger :err &quot;DATA-RECEIVED-HANDLER GOT ERROR: ~A&quot; condition)))))

(defun create-input-handler (stream fd)
  (handler-case
      (sb-sys:add-fd-handler
       fd :input
       #&#039;(lambda (fd)
     (declare (ignore fd))
     (data-received-handler stream)))
    (error (condition)
      (logger :err &quot;Problem initiating fd handler: ~A&quot; condition)
      (close-serial fd))))

(defun activate-scanner (tty)
  (setf *barcode-reader-thread-off* nil)
  (setf *barcode-reader-queue* (sb-queue:make-queue))
  (setf *barcode-reader-thread*
  (sb-thread:make-thread
   #&#039;(lambda ()
       (multiple-value-bind (stream fd) (open-serial tty)
         (create-input-handler stream fd)
         (loop
      (if *barcode-reader-thread-off*
          (ignore-errors
      (close-serial fd)
      (return nil))
          (handler-case
        (sb-sys:serve-all-events 0.5)
      (error (condition)
        (ignore-errors (close-serial fd))
        (logger :err &quot;Unahndled error in barcode reader thread: ~A&quot; condition)
        (return nil)))))))
       :name &quot;scanner-thread&quot;)))

(defun deactivate-scanner ()
  (setf *barcode-reader-thread-off* t)
  (sb-thread:join-thread *barcode-reader-thread*)
  (setf *barcode-reader-thread* nil))</description>
		<content:encoded><![CDATA[<p>I use the following code in SBCL to speak to bar code scanners.  Perhaps it would be helpful to you?</p>
<p>(defun get-posix-baud (baud)<br />
  (when (stringp baud)<br />
    (setf baud (parse-integer baud)))<br />
  (case baud<br />
    (110       sb-posix:b110)<br />
    (300       sb-posix:b300)<br />
    (1200      sb-posix:b1200)<br />
    (2400      sb-posix:b2400)<br />
    (4800      sb-posix:b4800)<br />
    (9600      sb-posix:b9600)<br />
    (19200     sb-posix:b19200)<br />
    (38400     sb-posix:b38400)<br />
    (57600     sb-posix:b57600)<br />
    (115200    sb-posix:b115200)<br />
    (230400    sb-posix:b230400)<br />
    (otherwise sb-posix:b19200)))</p>
<p>(defun open-serial (tty &amp;optional (baud 9600))<br />
  (handler-case<br />
      (let* ((fd (sb-posix:open<br />
      tty<br />
      (boole boole-ior<br />
       (boole boole-ior sb-posix:O-RDWR sb-posix:O-NOCTTY)<br />
       sb-posix:O-NDELAY)))<br />
       (options (sb-posix:tcgetattr fd))<br />
       (serial-stream nil)<br />
       (posix-baud (get-posix-baud baud)))<br />
  (sb-posix:cfsetispeed posix-baud options)<br />
  (sb-posix:cfsetospeed posix-baud options)<br />
  (setf (sb-posix:termios-cflag options)<br />
        (boole boole-ior sb-posix:CLOCAL sb-posix:CREAD))<br />
  (setf (sb-posix:termios-cflag options)<br />
        (boole boole-and<br />
         (sb-posix:termios-cflag options) (boole boole-c1 sb-posix:PARENB 0)))<br />
  (setf (sb-posix:termios-cflag options)<br />
        (boole boole-and<br />
         (sb-posix:termios-cflag options) (boole boole-c1 sb-posix:CSTOPB 0)))<br />
  (setf (sb-posix:termios-cflag options)<br />
        (boole boole-and<br />
         (sb-posix:termios-cflag options) (boole boole-c1 sb-posix:CSIZE 0)))<br />
  (setf (sb-posix:termios-cflag options)<br />
        (boole boole-ior (sb-posix:termios-cflag options) sb-posix:CS8))<br />
  (sb-posix:tcsetattr fd sb-posix:TCSANOW options)<br />
  (setf serial-stream<br />
        (sb-sys:make-fd-stream fd :input t :output t :element-type &#8216;unsigned-byte :buffering :full))<br />
  (values serial-stream fd))<br />
    (error (condition)<br />
      (format t &#8220;Problem opening serial port ~A: ~A&#8221; tty condition))))</p>
<p>(defun close-serial (fd)<br />
  (sb-posix:fcntl fd sb-posix:F-SETFL 0)<br />
  (sb-posix:close fd))</p>
<p>(let ((bcode nil))<br />
  (defun data-received-handler (stream)<br />
    (logger :info &#8220;DATA-RECEIVED-HANDLER called on ~A&#8221; stream)<br />
    (handler-case<br />
  (let ((c nil))<br />
    (loop<br />
       (setf c (read-byte stream))<br />
       (logger :info &#8220;SERIAL GOT: ~A / ~A&#8221; c (code-char c))<br />
       (cond ((eql c 13)<br />
        (logger :info &#8220;ENQUEUEING ~A&#8221; (reverse bcode))<br />
        (sb-queue:enqueue (format nil &#8220;~{~a~}&#8221; (reverse bcode)) *barcode-reader-queue*)<br />
        (setf bcode nil))<br />
       ((eql c 10)  (return))<br />
       ((eql c 2)   (setf bcode nil))<br />
       (t           (push (code-char c) bcode)))))<br />
      (end-of-file (condition)<br />
  (declare (ignore condition)))<br />
      (error (condition)<br />
  (logger :err &#8220;DATA-RECEIVED-HANDLER GOT ERROR: ~A&#8221; condition)))))</p>
<p>(defun create-input-handler (stream fd)<br />
  (handler-case<br />
      (sb-sys:add-fd-handler<br />
       fd :input<br />
       #&#8217;(lambda (fd)<br />
     (declare (ignore fd))<br />
     (data-received-handler stream)))<br />
    (error (condition)<br />
      (logger :err &#8220;Problem initiating fd handler: ~A&#8221; condition)<br />
      (close-serial fd))))</p>
<p>(defun activate-scanner (tty)<br />
  (setf *barcode-reader-thread-off* nil)<br />
  (setf *barcode-reader-queue* (sb-queue:make-queue))<br />
  (setf *barcode-reader-thread*<br />
  (sb-thread:make-thread<br />
   #&#8217;(lambda ()<br />
       (multiple-value-bind (stream fd) (open-serial tty)<br />
         (create-input-handler stream fd)<br />
         (loop<br />
      (if *barcode-reader-thread-off*<br />
          (ignore-errors<br />
      (close-serial fd)<br />
      (return nil))<br />
          (handler-case<br />
        (sb-sys:serve-all-events 0.5)<br />
      (error (condition)<br />
        (ignore-errors (close-serial fd))<br />
        (logger :err &#8220;Unahndled error in barcode reader thread: ~A&#8221; condition)<br />
        (return nil)))))))<br />
       :name &#8220;scanner-thread&#8221;)))</p>
<p>(defun deactivate-scanner ()<br />
  (setf *barcode-reader-thread-off* t)<br />
  (sb-thread:join-thread *barcode-reader-thread*)<br />
  (setf *barcode-reader-thread* nil))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TY Chew</title>
		<link>http://ryepup.unwashedmeme.com/blog/2009/09/28/talking-usb-serial-to-my-arduino-from-lisp-sbcl-on-linux/comment-page-1/#comment-32312</link>
		<dc:creator>TY Chew</dc:creator>
		<pubDate>Tue, 29 Sep 2009 07:42:09 +0000</pubDate>
		<guid isPermaLink="false">http://ryepup.unwashedmeme.com/blog/?p=131#comment-32312</guid>
		<description>When I wanted an interactive &quot;REPL&quot; on an Atmel, I wrote a Forth to run on the chip instead. It&#039;s really cool because it&#039;s all self hosting, so I only need a serial connection to talk to it. All user defined programs (Forth words) sit in SRAM memory, so they are volatile. I haven&#039;t got around to flashing the program memory or the internal EEPROM, but that hasn&#039;t been a great issue: I just wanted to prototype things, and learn about the chip&#039;s capabilities.

It&#039;s not cool because being self hosting means it uses up a lot of memory. I&#039;m easily out of memory!

When I get around to it, I would probably investigate how to couple Lisp nicely into this system. Would you be keen to try this out? Fire me an email.</description>
		<content:encoded><![CDATA[<p>When I wanted an interactive &#8220;REPL&#8221; on an Atmel, I wrote a Forth to run on the chip instead. It&#8217;s really cool because it&#8217;s all self hosting, so I only need a serial connection to talk to it. All user defined programs (Forth words) sit in SRAM memory, so they are volatile. I haven&#8217;t got around to flashing the program memory or the internal EEPROM, but that hasn&#8217;t been a great issue: I just wanted to prototype things, and learn about the chip&#8217;s capabilities.</p>
<p>It&#8217;s not cool because being self hosting means it uses up a lot of memory. I&#8217;m easily out of memory!</p>
<p>When I get around to it, I would probably investigate how to couple Lisp nicely into this system. Would you be keen to try this out? Fire me an email.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.907 seconds -->

