Problem with SerialPort and Cog

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with SerialPort and Cog

Javier Diaz-Reinoso
This example don't work with Cog 4.0.2701 in a iMac OSX 10.8.3:

|p s|
p := SerialPort new.
p baudRate: 115200.
p openPort: '/dev/cu.usbmodem1a21'.

1 to: 5 do:[:i|
        s := p readString.
        Transcript show: 'i=', i asString, '=>', s, '<=';cr.
        (Delay forSeconds: 1) wait.
        i=1 ifTrue:[p nextPutAll: 'M105', String lf.]
].
p close.

the same code works ok with the Squeak 4.2.5beta1U, this is connected to an Arduino Mega using only a USB cable.


Reply | Threaded
Open this post in threaded view
|

Re: Problem with SerialPort and Cog

Eliot Miranda-2


On Tue, Apr 2, 2013 at 4:27 PM, Javier Diaz-Reinoso <[hidden email]> wrote:
This example don't work with Cog 4.0.2701 in a iMac OSX 10.8.3:

|p s|
p := SerialPort new.
p baudRate: 115200.
p openPort: '/dev/cu.usbmodem1a21'.

1 to: 5 do:[:i|
        s := p readString.
        Transcript show: 'i=', i asString, '=>', s, '<=';cr.
        (Delay forSeconds: 1) wait.
        i=1 ifTrue:[p nextPutAll: 'M105', String lf.]
].
p close.

the same code works ok with the Squeak 4.2.5beta1U, this is connected to an Arduino Mega using only a USB cable.

and how does it fail? 



Reply | Threaded
Open this post in threaded view
|

Re: Problem with SerialPort and Cog

Javier Diaz-Reinoso
After line: p openPort: '/dev/cu.usbmodem1a21'., p in Cog is:
        SerialPort(closed, 115200 baud, 8 bits, 1 stopbits, no parity)
is closed because port is nil, in Squeak 4.2.5beta1U is:
        SerialPort(#'/dev/cu.usbmodem1a21', 115200 baud, 8 bits, 1 stopbits, no parity)
port is: '/dev/cu.usbmodem1a21'.

I repeated my test with a virgin copy of Squeak4.4-12327 (before I was using 4.1 and 4.3), also with other macbook pro, the same error.

On 02/04/2013, at 19:00, Eliot Miranda <[hidden email]> wrote:

> On Tue, Apr 2, 2013 at 4:27 PM, Javier Diaz-Reinoso
> <[hidden email]>wrote:
>
>> This example don't work with Cog 4.0.2701 in a iMac OSX 10.8.3:
>>
>> |p s|
>> p := SerialPort new.
>> p baudRate: 115200.
>> p openPort: '/dev/cu.usbmodem1a21'.
>>
>> 1 to: 5 do:[:i|
>>        s := p readString.
>>        Transcript show: 'i=', i asString, '=>', s, '<=';cr.
>>        (Delay forSeconds: 1) wait.
>>        i=1 ifTrue:[p nextPutAll: 'M105', String lf.]
>> ].
>> p close.
>>
>> the same code works ok with the Squeak 4.2.5beta1U, this is connected to
>> an Arduino Mega using only a USB cable.
>>
>
> and how does it fail?
>


Reply | Threaded
Open this post in threaded view
|

Re: Problem with SerialPort and Cog

Javier Diaz-Reinoso
On 03/04/2013, at 10:53, Javier Diaz-Reinoso <[hidden email]> wrote:

> After line: p openPort: '/dev/cu.usbmodem1a21'., p in Cog is:
> SerialPort(closed, 115200 baud, 8 bits, 1 stopbits, no parity)
> is closed because port is nil, in Squeak 4.2.5beta1U is:
> SerialPort(#'/dev/cu.usbmodem1a21', 115200 baud, 8 bits, 1 stopbits, no parity)
> port is: '/dev/cu.usbmodem1a21'.
>
> I repeated my test with a virgin copy of Squeak4.4-12327 (before I was using 4.1 and 4.3), also with other macbook pro, the same error.
>
[cut...]

Well, I download the VM from www.squeakvm.org/svn/squeak/branches/Cog/ and find that primitiveSerialPortOpenByName is not defined!.

In /Tools/Squeak/VMCog/platforms/unix/plugins/SerialPlugin/sqUnixSerial.c (included in the CoreVM. xcodeproj) the function serialPortOpenByName is defined, but is not "linked" with primitiveSerialPortOpenByName so the call (in Squeak) of primOpenPortByName: fail.



Reply | Threaded
Open this post in threaded view
|

Re: Problem with SerialPort and Cog

Eliot Miranda-2


On Fri, Apr 5, 2013 at 2:37 PM, Javier Diaz-Reinoso <[hidden email]> wrote:
On 03/04/2013, at 10:53, Javier Diaz-Reinoso <[hidden email]> wrote:

> After line: p openPort: '/dev/cu.usbmodem1a21'., p in Cog is:
>       SerialPort(closed, 115200 baud, 8 bits, 1 stopbits, no parity)
> is closed because port is nil, in Squeak 4.2.5beta1U is:
>       SerialPort(#'/dev/cu.usbmodem1a21', 115200 baud, 8 bits, 1 stopbits, no parity)
> port is: '/dev/cu.usbmodem1a21'.
>
> I repeated my test with a virgin copy of Squeak4.4-12327 (before I was using 4.1 and 4.3), also with other macbook pro, the same error.
>
[cut...]

Well, I download the VM from www.squeakvm.org/svn/squeak/branches/Cog/ and find that primitiveSerialPortOpenByName is not defined!.

In /Tools/Squeak/VMCog/platforms/unix/plugins/SerialPlugin/sqUnixSerial.c (included in the CoreVM. xcodeproj) the function serialPortOpenByName is defined, but is not "linked" with primitiveSerialPortOpenByName so the call (in Squeak) of primOpenPortByName: fail.

Ah, right.  That's because there is no support on Mac OS or Windows.  So wen I tried adding  primitiveSerialPortOpenByName it broke the builds on Windows and Mac.  If anyone has support files for those platforms I'll try again.



--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: Problem with SerialPort and Cog

Javier Diaz-Reinoso
The problem is with the fork VMMaker.oscog, you need to re-sync SerialPort with the fork VMMaker.

VMMaker-dtl.315 had already the slang methods for the ByName variants, you can copy&paste or directly from Monticello browser replace the methods, then can generate a SerialPort.c with the new functions.

The files platforms/Mac OS/vm/osExports.c and platforms/Cross/plugins/SerialPlugin/SerialPlugin.h need add the new functions, I am attaching this files for your convenience.

Finally link with platforms/unix/plugins/SerialPlugin/sqUnixSerial.c instead of the obsolete platforms/Mac OS/plugins/SerialPlugin/sqMacSerialPort.c.

I tested a VM with this changes and appear to work OK.



On 06/04/2013, at 19:11, Eliot Miranda <[hidden email]> wrote:

> On Fri, Apr 5, 2013 at 2:37 PM, Javier Diaz-Reinoso
> <[hidden email]>wrote:
>
>> On 03/04/2013, at 10:53, Javier Diaz-Reinoso <[hidden email]>
>> wrote:
>>
>>> After line: p openPort: '/dev/cu.usbmodem1a21'., p in Cog is:
>>>      SerialPort(closed, 115200 baud, 8 bits, 1 stopbits, no parity)
>>> is closed because port is nil, in Squeak 4.2.5beta1U is:
>>>      SerialPort(#'/dev/cu.usbmodem1a21', 115200 baud, 8 bits, 1
>> stopbits, no parity)
>>> port is: '/dev/cu.usbmodem1a21'.
>>>
>>> I repeated my test with a virgin copy of Squeak4.4-12327 (before I was
>> using 4.1 and 4.3), also with other macbook pro, the same error.
>>>
>> [cut...]
>>
>> Well, I download the VM from www.squeakvm.org/svn/squeak/branches/Cog/and find that primitiveSerialPortOpenByName is not defined!.
>>
>> In /Tools/Squeak/VMCog/platforms/unix/plugins/SerialPlugin/sqUnixSerial.c
>> (included in the CoreVM. xcodeproj) the function serialPortOpenByName is
>> defined, but is not "linked" with primitiveSerialPortOpenByName so the call
>> (in Squeak) of primOpenPortByName: fail.
>>
>
> Ah, right.  That's because there is no support on Mac OS or Windows.  So
> wen I tried adding  primitiveSerialPortOpenByName it broke the builds on
> Windows and Mac.  If anyone has support files for those platforms I'll try
> again.
>
>
>
> --
> best,
> Eliot
>



extra.zip (1K) Download Attachment