Hi, I've been testing the patch for accessing named serial ports in Ubuntu 9.04 with an USB Arduino. I'm very grateful for this patch because it solves me a lot of problems.
Although it seems to be working fine, I have two questions: 1) Is it possible to access the list of available serial ports? (The official arduino software lets you choose from a list of serial ports and I would like to do the same). 2) The first time I open a port, it works fine. Then, if I close it and open it again, everytime I try #nextPutAll: I get a primitive fail. This happens with port numbers and with port names. The only workaround that I found is closing the Squeak image and open it again. Could it be a bug in the serial plugin? Again, thanks for this patch! Cheers. Richo |
>
>From: Ricardo Moran > .... >2) The first time I open a port, it works fine. Then, if I close it and open it again, everytime I try #nextPutAll: I get a primitive fail. This happens with port numbers and with port names. The only workaround that I found is closing the Squeak image and open it again. Could it be a bug in the serial plugin? Same here, except that SerialPort>>openPort: already fails. I checked with lsof and the file does get closed by the vm but any further opening attempt fails (Debian i586). Have fun, Markus |
Sorry for the post here, I subscribed to vm-dev but cannot post (yet).
I looked into it and there are 2 issues, one in the image and one in the vm. In SerialPort>>openPort: self close. (self primClosePort: portNumber) isNil ifTrue: [ ^ nil ]. ... 'self close' calls primClosePort: if no port is assigned. So calling primClosePort: explicitely will always call into the vm, although the port should already be closed. Maybe the intent is to safeguard agains 2 instances of SerialPort, but then the openPort: call to the second instance would invalidate the first anyway (which would still have port assigned). This is what happens: On calling openPort: a call into the vm is performed to close the port. That call (initially) bails out at line 180 in sqUnixSerial.c: ... if (sp == NULL || sp->spDescriptor < 0) { success(true); return 0; } ... because the the serial port was never used and no entry exists in the 'previousSerialFiles' table. Once the port was opened an entry is created but not destroyed on close. So when primClosePort is called by SerialPort>>openPort: an entry is found in previousSerialFiles and the vm actually tries to close that one (again). Which fails in line 186: ... if (tcsetattr(sp->spDescriptor, TCSAFLUSH, &sp->spTermios)) ... because the file descriptor is not open anymore. adding .... sp->spName[0] = '\0'; ... at the end of serialPortCloseByName fixes the problem (and doesn't require a change to SerialPort>>openPort:). Ha, that was fun, Markus ----- Original Message ---- > From: Markus Lampert > > > >From: Ricardo Moran > > .... > >2) The first time I open a port, it works fine. Then, if I close it and open it > again, everytime I try #nextPutAll: I get a primitive fail. This happens with > port numbers and with port names. The only workaround that I found is closing > the Squeak image and open it again. Could it be a bug in the serial plugin? > > Same here, except that SerialPort>>openPort: already fails. I checked with lsof > and the file does get closed by the vm but any further opening attempt fails > (Debian i586). > > Have fun, > Markus |
On Fri, Sep 18, 2009 at 06:29:15PM -0700, Markus Lampert wrote:
> > Once the port was opened an entry is created but not destroyed on close. So when primClosePort is called by SerialPort>>openPort: an entry is found in previousSerialFiles and the vm actually tries to close that one (again). Which fails in line 186: > ... Ian has apparently added your fix now: http://lists.squeakfoundation.org/pipermail/vm-dev/2009-September/003216.html So I think that the problem should now be resolved in future builds. Dave |
In reply to this post by Ricardo Moran
On Fri, Sep 18, 2009 at 06:25:59PM -0300, Ricardo Moran wrote:
> Hi, I've been testing the patch for accessing named serial ports in Ubuntu > 9.04 with an USB Arduino. I'm very grateful for this patch because it solves > me a lot of problems. > > Although it seems to be working fine, I have two questions: > > 1) Is it possible to access the list of available serial ports? (The > official arduino software lets you choose from a list of serial ports and I > would like to do the same). The plugin will not help with this, but you know the device names that you are looking for, you can just do something like this: pattern := '*usb*'. (FileDirectory on: '/dev') fileNames select: [:e | pattern match: e] thenCollect: [:e | '/dev/', e] > 2) The first time I open a port, it works fine. Then, if I close it and open > it again, everytime I try #nextPutAll: I get a primitive fail. This happens > with port numbers and with port names. The only workaround that I found is > closing the Squeak image and open it again. Could it be a bug in the serial > plugin? I think it's fixed in the latest Subversion sources now. Dave |
Thank you guys for the fix in the serial plugin and for the tip in how to get the list of available ports.
Cheers. On Sat, Sep 19, 2009 at 11:21 AM, David T. Lewis <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |