Hello,
I have finally make a little web page about my work with lego mindstorm. It works fine, but... I need help for getting out of my troubles with serial port.
LegoMindstorm on Squeak here : http://minnow.cc.gatech.edu/squeak/2412
Do not hesitate to inform me about your comment...
Best Regards, Alexandre
On Friday 29 March 2002 09:17 am, Bergel Alexandre wrote:
Hello,
I have finally make a little web page about my work with lego mindstorm. It works fine, but... I need help for getting out of my troubles with serial port.
LegoMindstorm on Squeak here : http://minnow.cc.gatech.edu/squeak/2412
Do not hesitate to inform me about your comment...
First, the version of sqUnixSerial.c you have seems to be broken. Make these changes:
RCS file: /cvsroot/squeak/squeak/platforms/unix/plugins/SerialPlugin/sqUnixSerial.c,v retrieving revision 1.1.1.1 diff -r1.1.1.1 sqUnixSerial.c 337c337 < /* defaultTermios.c_cflag = 0; */ ---
defaultTermios.c_cflag = CREAD;
341,342c341,342 < defaultTermios.c_cc[VTIME] = 5; < defaultTermios.c_cc[VMIN] = 1; ---
defaultTermios.c_cc[VTIME] = 0; defaultTermios.c_cc[VMIN] = 0;
Second, you really don't want blocking I/O for the serial port. Not even if you think you do. If you use blocking I/O nothing at all will happen while you're waiting for bytes.
We need to provide real Semaphore signaling for the serial ports like there is for the Sockets, but until that time, is there some reason why you can't just do polling?
That is: have a background Process that does nothing but receive bytes, stuffing received strings into a SharedQueue. This would be polling at a reasonable rate. Of course, you would have to assemble the received fragments at the other end.
That is, this Workspace code works fine for me on Linux:
queue _ SharedQueue new. port _ SerialPort new openPort: 5.
"Receive loop" [ | delay buffer bytesRead | delay _ Delay forMilliseconds: 200. buffer _ String new: 100. [ delay wait. bytesRead _ port readInto: buffer startingAt: 1. bytesRead > 0 ifTrue: [ queue nextPut: (buffer copyFrom: 1 to: bytesRead). ]. ] repeat. ] forkAt: Processor userInterruptPriority.
"Foreground process"
[ queue size > 0 ifTrue: [ Transcript show: queue next ]. World doOneCycle. ] repeat.
On Friday 29 March 2002 10:02 am, Ned Konz wrote:
"Foreground process"
[ queue size > 0 ifTrue: [ Transcript show: queue next ]. World doOneCycle. ] repeat.
er, make that
queue size > 0 whileTrue: [ Transcript show: queue next ].
Thanks Ned for your answer,
But I have done something similar (cf RCXSerialPortReader class) I guess. I really do not understand why I have a different behavior if I use a VM with O_NONBLOCK ?
Thank you, Alexandre
On Fri, Mar 29, 2002 at 10:10:39AM -0800, Ned Konz wrote:
On Friday 29 March 2002 10:02 am, Ned Konz wrote:
"Foreground process"
[ queue size > 0 ifTrue: [ Transcript show: queue next ]. World doOneCycle. ] repeat.
er, make that
queue size > 0 whileTrue: [ Transcript show: queue next ].
-- Ned Konz currently: Stanwood, WA email: ned@bike-nomad.com homepage: http://bike-nomad.com
On Saturday 30 March 2002 07:16 am, Bergel Alexandre wrote:
Thanks Ned for your answer,
But I have done something similar (cf RCXSerialPortReader class) I guess. I really do not understand why I have a different behavior if I use a VM with O_NONBLOCK ?
First, have you tried using the VM changes I supplied? I don't know why you're able to read any bytes at all without the CREAD bit set.
With the VM you have, VMIN is set to 1, and VTIME is set to 5.
MIN represents the minimum number of characters that should be received to satisfy the read. TIME is a decisecond-valued timer. When both are set, a read will wait until at least one character has been received, and then return as soon as either MIN characters have been received or time TIME has passed since the last character was received.
So if you set blocking mode and use the VMIN and VTIME values that you have, a read will return when either:
* 1 character or more has been received, or * at least 50msec has passed since the last character.
It's up to you. But I would try making sure that the CREAD bit was set.
If I get some time, I may try your code with my RCX.
Bergel Alexandre wrote:
I have finally make a little web page about my work with lego mindstorm. It works fine, but... I need help for getting out of my troubles with serial port.
LegoMindstorm on Squeak here : http://minnow.cc.gatech.edu/squeak/2412
Do not hesitate to inform me about your comment...
Looks good!
Just a small complaint about adding Swiki pages, though... When adding a new wiki page, try to check to see if there is already a page covering the same topic (by doing a search if necessary).
In your case, there was already a "Lego Mindstorms" page at http://minnow.cc.gatech.edu/squeak/1872 , so you may not have needed to create a sort-of duplicate page. (You could have found this page by doing a search on the Swiki for "Lego".) Possibly combining the content of the two pages might be a good idea, or at the very least you should add a link from your page to the other one and vice versa.
The Swiki needs more of this sort of cleanup in general... removing duplication, and adding more cross-referencing of related material. I've created a couple of pages about this on the Swiki. See:
"Refactoring the Swiki" http://minnow.cc.gatech.edu/squeak/2352 "An Encyclopedic Swiki" http://minnow.cc.gatech.edu/squeak/2348
Please help to refactor the Swiki occasionally as you use it. (Especially when adding new pages!)
- Doug Way dway@riskmetrics.com
I've been looking at various approaches to using Squeak to send Consumer infrared remote control signals.
I've been looking at LIRC and at various places around the web but haven't found anything that seems easy to adopt. I am specifically looking for an iPaq solution, but a cross-platform approach would be desirable.
Has anybody done anything with Squeak in this area? I know the Mindstorm kit uses consumer IR.
My guess is that it isn't too hard to code, if one only knows what one's doing (and I don't). A Slang primitive for sending the signals, and then the rest in ordinary Smalltalk. The problem with the primitive seems to be getting the timing right.
Henrik
On Tue, Apr 02, 2002 at 06:54:20PM +0100, Henrik Gedenryd wrote:
I've been looking at various approaches to using Squeak to send Consumer infrared remote control signals.
I've been looking at LIRC and at various places around the web but haven't found anything that seems easy to adopt. I am specifically looking for an iPaq solution, but a cross-platform approach would be desirable.
Has anybody done anything with Squeak in this area? I know the Mindstorm kit uses consumer IR.
Well, I wrote an Squeak-based driver for X10 wireless remotes...that's not IR though, it's RF. And actually, the only thing I had to worry about was serial communications in the end. :)
My guess is that it isn't too hard to code, if one only knows what one's doing (and I don't). A Slang primitive for sending the signals, and then the rest in ordinary Smalltalk. The problem with the primitive seems to be getting the timing right.
Henrik
Oh, I see...you're going in the opposite direction I am. :) My driver is for receiving signals (controlling Squeak via remote)...yours would be for sending IR signals, correct?
I had considered a 'quick and dirty' way of doing this on my iPaq via Squeak at one time. If you're in Linux-land, there are a bunch of command-line tools for manipulating the IR port...conceivably you could hack something together with OSProcess to do it. Of course, that's not nearly as portable as a primitive.
Hello,
The immediate mode example from the swiki to beep the RCX works on Win98 with 3.2gamma-4811.
regards
squeak-dev@lists.squeakfoundation.org