VM Maker: VMMaker.oscog-ul.2354.mcz

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

VM Maker: VMMaker.oscog-ul.2354.mcz

commits-2
 
Levente Uzonyi uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-ul.2354.mcz

==================== Summary ====================

Name: VMMaker.oscog-ul.2354
Author: ul
Time: 10 March 2018, 10:56:45.349653 pm
UUID: b8f3192d-2b33-4a5d-83f9-785fbefbc570
Ancestors: VMMaker.oscog-eem.2353

Restored SerialPlugin's *byName* primitives on non-PharoVM VMs.

=============== Diff against VMMaker.oscog-eem.2353 ===============

Item was changed:
  ----- Method: SerialPlugin>>primitiveSerialPortOpenByName:baudRate:stopBitsType:parityType:dataBits:inFlowControlType:outFlowControlType:xOnByte:xOffByte: (in category 'primitives') -----
  primitiveSerialPortOpenByName: portName baudRate: baudRate stopBitsType: stopBitsType parityType: parityType dataBits: dataBits inFlowControlType: inFlowControl outFlowControlType: outFlowControl xOnByte: xOnChar xOffByte: xOffChar
- <option: #PharoVM>
  <var: #port type: 'char *'>
 
  | port portNameSize |
 
  self primitive: 'primitiveSerialPortOpenByName'
  parameters: #(String SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger ).
 
  portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
  port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
  self cCode: 'memcpy(port, portName, portNameSize)'.
 
  self cCode: 'serialPortOpenByName(
  port, baudRate, stopBitsType, parityType, dataBits,
  inFlowControl, outFlowControl, xOnChar, xOffChar)'.
 
  self free: port.!

Item was changed:
  ----- Method: SerialPlugin>>primitiveSerialPortReadByName:into:startingAt:count: (in category 'primitives') -----
  primitiveSerialPortReadByName: portName into: array startingAt: startIndex count: count
- <option: #PharoVM>
  <var: #port type: 'char *'>
 
  | port portNameSize bytesRead arrayPtr |
 
  self primitive: 'primitiveSerialPortReadByName'
  parameters: #(String  ByteArray SmallInteger SmallInteger ).
 
  interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
  "adjust for zero-origin indexing"
 
  portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
  port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
  self cCode: 'memcpy(port, portName, portNameSize)'.
 
  arrayPtr := array + startIndex - 1.
  bytesRead := self cCode: 'serialPortReadIntoByName( port, count, arrayPtr)'.
 
  self free: port.
 
  ^ bytesRead asSmallIntegerObj!

Item was changed:
  ----- Method: SerialPlugin>>primitiveSerialPortWriteByName:from:startingAt:count: (in category 'primitives') -----
  primitiveSerialPortWriteByName: portName from: array startingAt: startIndex count: count
- <option: #PharoVM>
  <var: #port type: 'char *'>
 
  | bytesWritten arrayPtr portNameSize port |
 
  self primitive: 'primitiveSerialPortWriteByName'
  parameters: #(String ByteArray SmallInteger SmallInteger ).
 
  portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
  port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
  self cCode: 'memcpy(port, portName, portNameSize)'.
 
  interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
  interpreterProxy failed
  ifFalse: [arrayPtr := array + startIndex - 1.
  bytesWritten := self cCode: 'serialPortWriteFromByName(port, count, arrayPtr)' ].
 
  self free: port.
 
  ^ bytesWritten asSmallIntegerObj!

Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker.oscog-ul.2354.mcz

Eliot Miranda-2
 
Hi Levente,

    when I try and build on Mac OS X I get this:

  "_serialPortOpenByName", referenced from:
      _primitiveSerialPortOpenByName in SerialPlugin.lib(SerialPlugin.o)
  "_serialPortReadIntoByName", referenced from:
      _primitiveSerialPortReadByName in SerialPlugin.lib(SerialPlugin.o)
  "_serialPortWriteFromByName", referenced from:
      _primitiveSerialPortWriteByName in SerialPlugin.lib(SerialPlugin.o)

The implementations are missing in both platforms/Mac OS/plugins/SerialPlugin/sqMacSerialPort.c and platforms/iOS/plugins/SerialPlugin/sqMacSerialPort.c.  They are there in platforms/unix/plugins/SerialPlugin/sqUnixSerial.c and platforms/win32/plugins/SerialPlugin/sqWin32SerialPort.c.

:-(


On Sat, Mar 10, 2018 at 1:58 PM, <[hidden email]> wrote:

Levente Uzonyi uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-ul.2354.mcz

==================== Summary ====================

Name: VMMaker.oscog-ul.2354
Author: ul
Time: 10 March 2018, 10:56:45.349653 pm
UUID: b8f3192d-2b33-4a5d-83f9-785fbefbc570
Ancestors: VMMaker.oscog-eem.2353

Restored SerialPlugin's *byName* primitives on non-PharoVM VMs.

=============== Diff against VMMaker.oscog-eem.2353 ===============

Item was changed:
  ----- Method: SerialPlugin>>primitiveSerialPortOpenByName:baudRate:stopBitsType:parityType:dataBits:inFlowControlType:outFlowControlType:xOnByte:xOffByte: (in category 'primitives') -----
  primitiveSerialPortOpenByName: portName baudRate: baudRate stopBitsType: stopBitsType parityType: parityType dataBits: dataBits inFlowControlType: inFlowControl outFlowControlType: outFlowControl xOnByte: xOnChar xOffByte: xOffChar
-       <option: #PharoVM>
        <var: #port type: 'char *'>

        | port portNameSize |

        self primitive: 'primitiveSerialPortOpenByName'
                parameters: #(String SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger ).

        portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
        port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
        self cCode: 'memcpy(port, portName, portNameSize)'.

        self cCode: 'serialPortOpenByName(
                        port, baudRate, stopBitsType, parityType, dataBits,
                        inFlowControl, outFlowControl, xOnChar, xOffChar)'.

        self free: port.!

Item was changed:
  ----- Method: SerialPlugin>>primitiveSerialPortReadByName:into:startingAt:count: (in category 'primitives') -----
  primitiveSerialPortReadByName: portName into: array startingAt: startIndex count: count
-       <option: #PharoVM>
        <var: #port type: 'char *'>

        | port portNameSize bytesRead arrayPtr |

        self primitive: 'primitiveSerialPortReadByName'
                parameters: #(String  ByteArray SmallInteger SmallInteger ).

        interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
        "adjust for zero-origin indexing"

        portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
        port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
        self cCode: 'memcpy(port, portName, portNameSize)'.

        arrayPtr := array + startIndex - 1.
        bytesRead := self cCode: 'serialPortReadIntoByName( port, count, arrayPtr)'.

        self free: port.

        ^ bytesRead asSmallIntegerObj!

Item was changed:
  ----- Method: SerialPlugin>>primitiveSerialPortWriteByName:from:startingAt:count: (in category 'primitives') -----
  primitiveSerialPortWriteByName: portName from: array startingAt: startIndex count: count
-       <option: #PharoVM>
        <var: #port type: 'char *'>

        | bytesWritten arrayPtr portNameSize port |

        self primitive: 'primitiveSerialPortWriteByName'
                parameters: #(String ByteArray SmallInteger SmallInteger ).

        portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
        port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
        self cCode: 'memcpy(port, portName, portNameSize)'.

        interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
        interpreterProxy failed
                ifFalse: [arrayPtr := array + startIndex - 1.
                        bytesWritten := self cCode: 'serialPortWriteFromByName(port, count, arrayPtr)' ].

        self free: port.

        ^ bytesWritten asSmallIntegerObj!




--
_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker.oscog-ul.2354.mcz

Eliot Miranda-2
 
Hi Levente,

   no need for any action on your part.  I see that the Serial Port primitives are essentially unimplemented on Mac OS so it is trivial to provide null implementations for the "ByName" ones.

On Fri, Mar 16, 2018 at 3:46 PM, Eliot Miranda <[hidden email]> wrote:
Hi Levente,

    when I try and build on Mac OS X I get this:

  "_serialPortOpenByName", referenced from:
      _primitiveSerialPortOpenByName in SerialPlugin.lib(SerialPlugin.o)
  "_serialPortReadIntoByName", referenced from:
      _primitiveSerialPortReadByName in SerialPlugin.lib(SerialPlugin.o)
  "_serialPortWriteFromByName", referenced from:
      _primitiveSerialPortWriteByName in SerialPlugin.lib(SerialPlugin.o)

The implementations are missing in both platforms/Mac OS/plugins/SerialPlugin/sqMacSerialPort.c and platforms/iOS/plugins/SerialPlugin/sqMacSerialPort.c.  They are there in platforms/unix/plugins/SerialPlugin/sqUnixSerial.c and platforms/win32/plugins/SerialPlugin/sqWin32SerialPort.c.

:-(


On Sat, Mar 10, 2018 at 1:58 PM, <[hidden email]> wrote:

Levente Uzonyi uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-ul.2354.mcz

==================== Summary ====================

Name: VMMaker.oscog-ul.2354
Author: ul
Time: 10 March 2018, 10:56:45.349653 pm
UUID: b8f3192d-2b33-4a5d-83f9-785fbefbc570
Ancestors: VMMaker.oscog-eem.2353

Restored SerialPlugin's *byName* primitives on non-PharoVM VMs.

=============== Diff against VMMaker.oscog-eem.2353 ===============

Item was changed:
  ----- Method: SerialPlugin>>primitiveSerialPortOpenByName:baudRate:stopBitsType:parityType:dataBits:inFlowControlType:outFlowControlType:xOnByte:xOffByte: (in category 'primitives') -----
  primitiveSerialPortOpenByName: portName baudRate: baudRate stopBitsType: stopBitsType parityType: parityType dataBits: dataBits inFlowControlType: inFlowControl outFlowControlType: outFlowControl xOnByte: xOnChar xOffByte: xOffChar
-       <option: #PharoVM>
        <var: #port type: 'char *'>

        | port portNameSize |

        self primitive: 'primitiveSerialPortOpenByName'
                parameters: #(String SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger ).

        portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
        port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
        self cCode: 'memcpy(port, portName, portNameSize)'.

        self cCode: 'serialPortOpenByName(
                        port, baudRate, stopBitsType, parityType, dataBits,
                        inFlowControl, outFlowControl, xOnChar, xOffChar)'.

        self free: port.!

Item was changed:
  ----- Method: SerialPlugin>>primitiveSerialPortReadByName:into:startingAt:count: (in category 'primitives') -----
  primitiveSerialPortReadByName: portName into: array startingAt: startIndex count: count
-       <option: #PharoVM>
        <var: #port type: 'char *'>

        | port portNameSize bytesRead arrayPtr |

        self primitive: 'primitiveSerialPortReadByName'
                parameters: #(String  ByteArray SmallInteger SmallInteger ).

        interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
        "adjust for zero-origin indexing"

        portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
        port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
        self cCode: 'memcpy(port, portName, portNameSize)'.

        arrayPtr := array + startIndex - 1.
        bytesRead := self cCode: 'serialPortReadIntoByName( port, count, arrayPtr)'.

        self free: port.

        ^ bytesRead asSmallIntegerObj!

Item was changed:
  ----- Method: SerialPlugin>>primitiveSerialPortWriteByName:from:startingAt:count: (in category 'primitives') -----
  primitiveSerialPortWriteByName: portName from: array startingAt: startIndex count: count
-       <option: #PharoVM>
        <var: #port type: 'char *'>

        | bytesWritten arrayPtr portNameSize port |

        self primitive: 'primitiveSerialPortWriteByName'
                parameters: #(String ByteArray SmallInteger SmallInteger ).

        portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
        port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
        self cCode: 'memcpy(port, portName, portNameSize)'.

        interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
        interpreterProxy failed
                ifFalse: [arrayPtr := array + startIndex - 1.
                        bytesWritten := self cCode: 'serialPortWriteFromByName(port, count, arrayPtr)' ].

        self free: port.

        ^ bytesWritten asSmallIntegerObj!




--
_,,,^..^,,,_
best, Eliot



--
_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker.oscog-ul.2354.mcz

Levente Uzonyi
 
Hi Eliot,

I wonder how the Pharo builds handle those. Because these have always been
enabled there.
Also, these primitives are from the original SqueakVM branch
(interpreter), so there should be problems as well if the primitives are
missing.

Levente

On Fri, 16 Mar 2018, Eliot Miranda wrote:

> Hi Levente,
>    no need for any action on your part.  I see that the Serial Port primitives are essentially unimplemented on Mac OS so it is trivial to provide null implementations for the "ByName" ones.
>
> On Fri, Mar 16, 2018 at 3:46 PM, Eliot Miranda <[hidden email]> wrote:
>       Hi Levente,
>     when I try and build on Mac OS X I get this:
>
>   "_serialPortOpenByName", referenced from:
>       _primitiveSerialPortOpenByName in SerialPlugin.lib(SerialPlugin.o)
>   "_serialPortReadIntoByName", referenced from:
>       _primitiveSerialPortReadByName in SerialPlugin.lib(SerialPlugin.o)
>   "_serialPortWriteFromByName", referenced from:
>       _primitiveSerialPortWriteByName in SerialPlugin.lib(SerialPlugin.o)
>
> The implementations are missing in both platforms/Mac OS/plugins/SerialPlugin/sqMacSerialPort.c and platforms/iOS/plugins/SerialPlugin/sqMacSerialPort.c.  They are there in
> platforms/unix/plugins/SerialPlugin/sqUnixSerial.c and platforms/win32/plugins/SerialPlugin/sqWin32SerialPort.c.
>
> :-(
>
>
> On Sat, Mar 10, 2018 at 1:58 PM, <[hidden email]> wrote:
>
>       Levente Uzonyi uploaded a new version of VMMaker to project VM Maker:
>       http://source.squeak.org/VMMaker/VMMaker.oscog-ul.2354.mcz
>
>       ==================== Summary ====================
>
>       Name: VMMaker.oscog-ul.2354
>       Author: ul
>       Time: 10 March 2018, 10:56:45.349653 pm
>       UUID: b8f3192d-2b33-4a5d-83f9-785fbefbc570
>       Ancestors: VMMaker.oscog-eem.2353
>
>       Restored SerialPlugin's *byName* primitives on non-PharoVM VMs.
>
>       =============== Diff against VMMaker.oscog-eem.2353 ===============
>
>       Item was changed:
>         ----- Method: SerialPlugin>>primitiveSerialPortOpenByName:baudRate:stopBitsType:parityType:dataBits:inFlowControlType:outFlowControlType:xOnByte:xOffByte: (in category 'primitives') -----
>         primitiveSerialPortOpenByName: portName baudRate: baudRate stopBitsType: stopBitsType parityType: parityType dataBits: dataBits inFlowControlType: inFlowControl outFlowControlType:
>       outFlowControl xOnByte: xOnChar xOffByte: xOffChar
>       -       <option: #PharoVM>
>               <var: #port type: 'char *'>
>
>               | port portNameSize |
>
>               self primitive: 'primitiveSerialPortOpenByName'
>                       parameters: #(String SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger ).
>
>               portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
>               port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
>               self cCode: 'memcpy(port, portName, portNameSize)'.
>
>               self cCode: 'serialPortOpenByName(
>                               port, baudRate, stopBitsType, parityType, dataBits,
>                               inFlowControl, outFlowControl, xOnChar, xOffChar)'.
>
>               self free: port.!
>
>       Item was changed:
>         ----- Method: SerialPlugin>>primitiveSerialPortReadByName:into:startingAt:count: (in category 'primitives') -----
>         primitiveSerialPortReadByName: portName into: array startingAt: startIndex count: count
>       -       <option: #PharoVM>
>               <var: #port type: 'char *'>
>
>               | port portNameSize bytesRead arrayPtr |
>
>               self primitive: 'primitiveSerialPortReadByName'
>                       parameters: #(String  ByteArray SmallInteger SmallInteger ).
>
>               interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
>               "adjust for zero-origin indexing"
>
>               portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
>               port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
>               self cCode: 'memcpy(port, portName, portNameSize)'.
>
>               arrayPtr := array + startIndex - 1.
>               bytesRead := self cCode: 'serialPortReadIntoByName( port, count, arrayPtr)'.
>
>               self free: port.
>
>               ^ bytesRead asSmallIntegerObj!
>
>       Item was changed:
>         ----- Method: SerialPlugin>>primitiveSerialPortWriteByName:from:startingAt:count: (in category 'primitives') -----
>         primitiveSerialPortWriteByName: portName from: array startingAt: startIndex count: count
>       -       <option: #PharoVM>
>               <var: #port type: 'char *'>
>
>               | bytesWritten arrayPtr portNameSize port |
>
>               self primitive: 'primitiveSerialPortWriteByName'
>                       parameters: #(String ByteArray SmallInteger SmallInteger ).
>
>               portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
>               port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
>               self cCode: 'memcpy(port, portName, portNameSize)'.
>
>               interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
>               interpreterProxy failed
>                       ifFalse: [arrayPtr := array + startIndex - 1.
>                               bytesWritten := self cCode: 'serialPortWriteFromByName(port, count, arrayPtr)' ].
>
>               self free: port.
>
>               ^ bytesWritten asSmallIntegerObj!
>
>
>
>
> --
> _,,,^..^,,,_
> best, Eliot
>
>
>
>
> --
> _,,,^..^,,,_
> best, Eliot
>
>
Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker.oscog-ul.2354.mcz

Clément Bera-4
 


On Sat, Mar 17, 2018 at 1:09 AM, Levente Uzonyi <[hidden email]> wrote:
 
Hi Eliot,

I wonder how the Pharo builds handle those. Because these have always been enabled there.
Also, these primitives are from the original SqueakVM branch (interpreter), so there should be problems as well if the primitives are missing.

Levente

On Fri, 16 Mar 2018, Eliot Miranda wrote:

Hi Levente,
   no need for any action on your part.  I see that the Serial Port primitives are essentially unimplemented on Mac OS so it is trivial to provide null implementations for the "ByName" ones.

Last time I talked with the people using the SerialPort plugin they said on Mac they use the linux plugin since the Mac plugin is not implemented, the linux plugin is, and the linux plugin works on all unix systems including Mac.

 

On Fri, Mar 16, 2018 at 3:46 PM, Eliot Miranda <[hidden email]> wrote:
      Hi Levente,
    when I try and build on Mac OS X I get this:

  "_serialPortOpenByName", referenced from:
      _primitiveSerialPortOpenByName in SerialPlugin.lib(SerialPlugin.o)
  "_serialPortReadIntoByName", referenced from:
      _primitiveSerialPortReadByName in SerialPlugin.lib(SerialPlugin.o)
  "_serialPortWriteFromByName", referenced from:
      _primitiveSerialPortWriteByName in SerialPlugin.lib(SerialPlugin.o)

The implementations are missing in both platforms/Mac OS/plugins/SerialPlugin/sqMacSerialPort.c and platforms/iOS/plugins/SerialPlugin/sqMacSerialPort.c.  They are there in
platforms/unix/plugins/SerialPlugin/sqUnixSerial.c and platforms/win32/plugins/SerialPlugin/sqWin32SerialPort.c.

:-(


On Sat, Mar 10, 2018 at 1:58 PM, <[hidden email]> wrote:

      Levente Uzonyi uploaded a new version of VMMaker to project VM Maker:
      http://source.squeak.org/VMMaker/VMMaker.oscog-ul.2354.mcz

      ==================== Summary ====================

      Name: VMMaker.oscog-ul.2354
      Author: ul
      Time: 10 March 2018, 10:56:45.349653 pm
      UUID: b8f3192d-2b33-4a5d-83f9-785fbefbc570
      Ancestors: VMMaker.oscog-eem.2353

      Restored SerialPlugin's *byName* primitives on non-PharoVM VMs.

      =============== Diff against VMMaker.oscog-eem.2353 ===============

      Item was changed:
        ----- Method: SerialPlugin>>primitiveSerialPortOpenByName:baudRate:stopBitsType:parityType:dataBits:inFlowControlType:outFlowControlType:xOnByte:xOffByte: (in category 'primitives') -----
        primitiveSerialPortOpenByName: portName baudRate: baudRate stopBitsType: stopBitsType parityType: parityType dataBits: dataBits inFlowControlType: inFlowControl outFlowControlType:
      outFlowControl xOnByte: xOnChar xOffByte: xOffChar
      -       <option: #PharoVM>
              <var: #port type: 'char *'>

              | port portNameSize |

              self primitive: 'primitiveSerialPortOpenByName'
                      parameters: #(String SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger ).

              portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
              port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
              self cCode: 'memcpy(port, portName, portNameSize)'.

              self cCode: 'serialPortOpenByName(
                              port, baudRate, stopBitsType, parityType, dataBits,
                              inFlowControl, outFlowControl, xOnChar, xOffChar)'.

              self free: port.!

      Item was changed:
        ----- Method: SerialPlugin>>primitiveSerialPortReadByName:into:startingAt:count: (in category 'primitives') -----
        primitiveSerialPortReadByName: portName into: array startingAt: startIndex count: count
      -       <option: #PharoVM>
              <var: #port type: 'char *'>

              | port portNameSize bytesRead arrayPtr |

              self primitive: 'primitiveSerialPortReadByName'
                      parameters: #(String  ByteArray SmallInteger SmallInteger ).

              interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
              "adjust for zero-origin indexing"

              portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
              port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
              self cCode: 'memcpy(port, portName, portNameSize)'.

              arrayPtr := array + startIndex - 1.
              bytesRead := self cCode: 'serialPortReadIntoByName( port, count, arrayPtr)'.

              self free: port.

              ^ bytesRead asSmallIntegerObj!

      Item was changed:
        ----- Method: SerialPlugin>>primitiveSerialPortWriteByName:from:startingAt:count: (in category 'primitives') -----
        primitiveSerialPortWriteByName: portName from: array startingAt: startIndex count: count
      -       <option: #PharoVM>
              <var: #port type: 'char *'>

              | bytesWritten arrayPtr portNameSize port |

              self primitive: 'primitiveSerialPortWriteByName'
                      parameters: #(String ByteArray SmallInteger SmallInteger ).

              portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
              port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
              self cCode: 'memcpy(port, portName, portNameSize)'.

              interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
              interpreterProxy failed
                      ifFalse: [arrayPtr := array + startIndex - 1.
                              bytesWritten := self cCode: 'serialPortWriteFromByName(port, count, arrayPtr)' ].

              self free: port.

              ^ bytesWritten asSmallIntegerObj!




--
_,,,^..^,,,_
best, Eliot




--
_,,,^..^,,,_
best, Eliot





--
Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker.oscog-ul.2354.mcz

Javier Diaz-Reinoso
 
Yes that is right, you can use sqUnixSerial.c instead of the sqMacSerialPort.c but there are limitation about the maximum speed, I have a hacked version of sqUnixSerial.c using the the same way that pyserial use, using this file my program sqPronterface works well at 250000 bps in intel mac, and a maximum of  230400 bps in ppc mac:




On 17 Mar 2018, at 03:02, Clément Bera <[hidden email]> wrote:



On Sat, Mar 17, 2018 at 1:09 AM, Levente Uzonyi <[hidden email]> wrote:
 
Hi Eliot,

I wonder how the Pharo builds handle those. Because these have always been enabled there.
Also, these primitives are from the original SqueakVM branch (interpreter), so there should be problems as well if the primitives are missing.

Levente

On Fri, 16 Mar 2018, Eliot Miranda wrote:

Hi Levente,
   no need for any action on your part.  I see that the Serial Port primitives are essentially unimplemented on Mac OS so it is trivial to provide null implementations for the "ByName" ones.

Last time I talked with the people using the SerialPort plugin they said on Mac they use the linux plugin since the Mac plugin is not implemented, the linux plugin is, and the linux plugin works on all unix systems including Mac.

 

On Fri, Mar 16, 2018 at 3:46 PM, Eliot Miranda <[hidden email]> wrote:
      Hi Levente,
    when I try and build on Mac OS X I get this:

  "_serialPortOpenByName", referenced from:
      _primitiveSerialPortOpenByName in SerialPlugin.lib(SerialPlugin.o)
  "_serialPortReadIntoByName", referenced from:
      _primitiveSerialPortReadByName in SerialPlugin.lib(SerialPlugin.o)
  "_serialPortWriteFromByName", referenced from:
      _primitiveSerialPortWriteByName in SerialPlugin.lib(SerialPlugin.o)

The implementations are missing in both platforms/Mac OS/plugins/SerialPlugin/sqMacSerialPort.c and platforms/iOS/plugins/SerialPlugin/sqMacSerialPort.c.  They are there in
platforms/unix/plugins/SerialPlugin/sqUnixSerial.c and platforms/win32/plugins/SerialPlugin/sqWin32SerialPort.c.

:-(


On Sat, Mar 10, 2018 at 1:58 PM, <[hidden email]> wrote:

      Levente Uzonyi uploaded a new version of VMMaker to project VM Maker:
      http://source.squeak.org/VMMaker/VMMaker.oscog-ul.2354.mcz

      ==================== Summary ====================

      Name: VMMaker.oscog-ul.2354
      Author: ul
      Time: 10 March 2018, 10:56:45.349653 pm
      UUID: b8f3192d-2b33-4a5d-83f9-785fbefbc570
      Ancestors: VMMaker.oscog-eem.2353

      Restored SerialPlugin's *byName* primitives on non-PharoVM VMs.

      =============== Diff against VMMaker.oscog-eem.2353 ===============

      Item was changed:
        ----- Method: SerialPlugin>>primitiveSerialPortOpenByName:baudRate:stopBitsType:parityType:dataBits:inFlowControlType:outFlowControlType:xOnByte:xOffByte: (in category 'primitives') -----
        primitiveSerialPortOpenByName: portName baudRate: baudRate stopBitsType: stopBitsType parityType: parityType dataBits: dataBits inFlowControlType: inFlowControl outFlowControlType:
      outFlowControl xOnByte: xOnChar xOffByte: xOffChar
      -       <option: #PharoVM>
              <var: #port type: 'char *'>

              | port portNameSize |

              self primitive: 'primitiveSerialPortOpenByName'
                      parameters: #(String SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger ).

              portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
              port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
              self cCode: 'memcpy(port, portName, portNameSize)'.

              self cCode: 'serialPortOpenByName(
                              port, baudRate, stopBitsType, parityType, dataBits,
                              inFlowControl, outFlowControl, xOnChar, xOffChar)'.

              self free: port.!

      Item was changed:
        ----- Method: SerialPlugin>>primitiveSerialPortReadByName:into:startingAt:count: (in category 'primitives') -----
        primitiveSerialPortReadByName: portName into: array startingAt: startIndex count: count
      -       <option: #PharoVM>
              <var: #port type: 'char *'>

              | port portNameSize bytesRead arrayPtr |

              self primitive: 'primitiveSerialPortReadByName'
                      parameters: #(String  ByteArray SmallInteger SmallInteger ).

              interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
              "adjust for zero-origin indexing"

              portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
              port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
              self cCode: 'memcpy(port, portName, portNameSize)'.

              arrayPtr := array + startIndex - 1.
              bytesRead := self cCode: 'serialPortReadIntoByName( port, count, arrayPtr)'.

              self free: port.

              ^ bytesRead asSmallIntegerObj!

      Item was changed:
        ----- Method: SerialPlugin>>primitiveSerialPortWriteByName:from:startingAt:count: (in category 'primitives') -----
        primitiveSerialPortWriteByName: portName from: array startingAt: startIndex count: count
      -       <option: #PharoVM>
              <var: #port type: 'char *'>

              | bytesWritten arrayPtr portNameSize port |

              self primitive: 'primitiveSerialPortWriteByName'
                      parameters: #(String ByteArray SmallInteger SmallInteger ).

              portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
              port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
              self cCode: 'memcpy(port, portName, portNameSize)'.

              interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
              interpreterProxy failed
                      ifFalse: [arrayPtr := array + startIndex - 1.
                              bytesWritten := self cCode: 'serialPortWriteFromByName(port, count, arrayPtr)' ].

              self free: port.

              ^ bytesWritten asSmallIntegerObj!




--
_,,,^..^,,,_
best, Eliot




--
_,,,^..^,,,_
best, Eliot





-- 


sqMacSerialV2.c.zip (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker.oscog-ul.2354.mcz

Guillermo Polito
 
Hi,

I've seen also some hiccups with that. I had students that could not use serial port on mac to connect to arduinos and they had to default to a linux virtual box or similar to work... :/

If there is an easy way to replace the "unimplemented" serial port by the unix one without duplicating the code that would be already an improvement by large and I would reaaaally be greatful. Then if there are bugs with reading speed, fixing one would suffice to fix both :).

I can offer myself to test on osx arduinos and maybe connecting to an xbox controller.

Tx!
Guille

On Sat, Mar 17, 2018 at 7:03 PM, Javier Diaz-Reinoso <[hidden email]> wrote:
 
Yes that is right, you can use sqUnixSerial.c instead of the sqMacSerialPort.c but there are limitation about the maximum speed, I have a hacked version of sqUnixSerial.c using the the same way that pyserial use, using this file my program sqPronterface works well at 250000 bps in intel mac, and a maximum of  230400 bps in ppc mac:




On 17 Mar 2018, at 03:02, Clément Bera <[hidden email]> wrote:



On Sat, Mar 17, 2018 at 1:09 AM, Levente Uzonyi <[hidden email]> wrote:
 
Hi Eliot,

I wonder how the Pharo builds handle those. Because these have always been enabled there.
Also, these primitives are from the original SqueakVM branch (interpreter), so there should be problems as well if the primitives are missing.

Levente

On Fri, 16 Mar 2018, Eliot Miranda wrote:

Hi Levente,
   no need for any action on your part.  I see that the Serial Port primitives are essentially unimplemented on Mac OS so it is trivial to provide null implementations for the "ByName" ones.

Last time I talked with the people using the SerialPort plugin they said on Mac they use the linux plugin since the Mac plugin is not implemented, the linux plugin is, and the linux plugin works on all unix systems including Mac.

 

On Fri, Mar 16, 2018 at 3:46 PM, Eliot Miranda <[hidden email]> wrote:
      Hi Levente,
    when I try and build on Mac OS X I get this:

  "_serialPortOpenByName", referenced from:
      _primitiveSerialPortOpenByName in SerialPlugin.lib(SerialPlugin.o)
  "_serialPortReadIntoByName", referenced from:
      _primitiveSerialPortReadByName in SerialPlugin.lib(SerialPlugin.o)
  "_serialPortWriteFromByName", referenced from:
      _primitiveSerialPortWriteByName in SerialPlugin.lib(SerialPlugin.o)

The implementations are missing in both platforms/Mac OS/plugins/SerialPlugin/sqMacSerialPort.c and platforms/iOS/plugins/SerialPlugin/sqMacSerialPort.c.  They are there in
platforms/unix/plugins/SerialPlugin/sqUnixSerial.c and platforms/win32/plugins/SerialPlugin/sqWin32SerialPort.c.

:-(


On Sat, Mar 10, 2018 at 1:58 PM, <[hidden email]> wrote:

      Levente Uzonyi uploaded a new version of VMMaker to project VM Maker:
      http://source.squeak.org/VMMaker/VMMaker.oscog-ul.2354.mcz

      ==================== Summary ====================

      Name: VMMaker.oscog-ul.2354
      Author: ul
      Time: 10 March 2018, 10:56:45.349653 pm
      UUID: b8f3192d-2b33-4a5d-83f9-785fbefbc570
      Ancestors: VMMaker.oscog-eem.2353

      Restored SerialPlugin's *byName* primitives on non-PharoVM VMs.

      =============== Diff against VMMaker.oscog-eem.2353 ===============

      Item was changed:
        ----- Method: SerialPlugin>>primitiveSerialPortOpenByName:baudRate:stopBitsType:parityType:dataBits:inFlowControlType:outFlowControlType:xOnByte:xOffByte: (in category 'primitives') -----
        primitiveSerialPortOpenByName: portName baudRate: baudRate stopBitsType: stopBitsType parityType: parityType dataBits: dataBits inFlowControlType: inFlowControl outFlowControlType:
      outFlowControl xOnByte: xOnChar xOffByte: xOffChar
      -       <option: #PharoVM>
              <var: #port type: 'char *'>

              | port portNameSize |

              self primitive: 'primitiveSerialPortOpenByName'
                      parameters: #(String SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger ).

              portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
              port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
              self cCode: 'memcpy(port, portName, portNameSize)'.

              self cCode: 'serialPortOpenByName(
                              port, baudRate, stopBitsType, parityType, dataBits,
                              inFlowControl, outFlowControl, xOnChar, xOffChar)'.

              self free: port.!

      Item was changed:
        ----- Method: SerialPlugin>>primitiveSerialPortReadByName:into:startingAt:count: (in category 'primitives') -----
        primitiveSerialPortReadByName: portName into: array startingAt: startIndex count: count
      -       <option: #PharoVM>
              <var: #port type: 'char *'>

              | port portNameSize bytesRead arrayPtr |

              self primitive: 'primitiveSerialPortReadByName'
                      parameters: #(String  ByteArray SmallInteger SmallInteger ).

              interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
              "adjust for zero-origin indexing"

              portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
              port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
              self cCode: 'memcpy(port, portName, portNameSize)'.

              arrayPtr := array + startIndex - 1.
              bytesRead := self cCode: 'serialPortReadIntoByName( port, count, arrayPtr)'.

              self free: port.

              ^ bytesRead asSmallIntegerObj!

      Item was changed:
        ----- Method: SerialPlugin>>primitiveSerialPortWriteByName:from:startingAt:count: (in category 'primitives') -----
        primitiveSerialPortWriteByName: portName from: array startingAt: startIndex count: count
      -       <option: #PharoVM>
              <var: #port type: 'char *'>

              | bytesWritten arrayPtr portNameSize port |

              self primitive: 'primitiveSerialPortWriteByName'
                      parameters: #(String ByteArray SmallInteger SmallInteger ).

              portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
              port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
              self cCode: 'memcpy(port, portName, portNameSize)'.

              interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
              interpreterProxy failed
                      ifFalse: [arrayPtr := array + startIndex - 1.
                              bytesWritten := self cCode: 'serialPortWriteFromByName(port, count, arrayPtr)' ].

              self free: port.

              ^ bytesWritten asSmallIntegerObj!




--
_,,,^..^,,,_
best, Eliot




--
_,,,^..^,,,_
best, Eliot





-- 





--

   

Guille Polito

Research Engineer

Centre de Recherche en Informatique, Signal et Automatique de Lille

CRIStAL - UMR 9189

French National Center for Scientific Research - http://www.cnrs.fr


Web: http://guillep.github.io

Phone: +33 06 52 70 66 13

Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker.oscog-ul.2354.mcz

Javier Diaz-Reinoso
 
I am not sure if the code of MacOS for "support arbitrary serial speeds" is valid in Linux, the code in pyserial (https://github.com/pyserial/pyserial/blob/master/serial/serialposix.py) is:

elif plat[:6] == 'darwin': # OS X
import array
IOSSIOSPEED = 0x80045402 # _IOW('T', 2, speed_t)
class PlatformSpecific(PlatformSpecificBase):
osx_version = os.uname()[2].split('.')
# Tiger or above can support arbitrary serial speeds
if int(osx_version[0]) >= 8:
def _set_special_baudrate(self, baudrate):
# use IOKit-specific call to set up high speeds
buf = array.array('i', [baudrate])
fcntl.ioctl(self.fd, IOSSIOSPEED, buf, 1)

can the equivalent in C work in linux or the other unix?.

At the moment I only use SqPronterface in mac (MacBook Pro or iBook G4) connected to an Arduino Mega controlling a Prusa  Mendel printer.


On 18 Mar 2018, at 05:29, Guillermo Polito <[hidden email]> wrote:

Hi,

I've seen also some hiccups with that. I had students that could not use serial port on mac to connect to arduinos and they had to default to a linux virtual box or similar to work... :/

If there is an easy way to replace the "unimplemented" serial port by the unix one without duplicating the code that would be already an improvement by large and I would reaaaally be greatful. Then if there are bugs with reading speed, fixing one would suffice to fix both :).

I can offer myself to test on osx arduinos and maybe connecting to an xbox controller.

Tx!
Guille

On Sat, Mar 17, 2018 at 7:03 PM, Javier Diaz-Reinoso <[hidden email]> wrote:
 
Yes that is right, you can use sqUnixSerial.c instead of the sqMacSerialPort.c but there are limitation about the maximum speed, I have a hacked version of sqUnixSerial.c using the the same way that pyserial use, using this file my program sqPronterface works well at 250000 bps in intel mac, and a maximum of  230400 bps in ppc mac:




On 17 Mar 2018, at 03:02, Clément Bera <[hidden email]> wrote:



On Sat, Mar 17, 2018 at 1:09 AM, Levente Uzonyi <[hidden email]> wrote:
 
Hi Eliot,

I wonder how the Pharo builds handle those. Because these have always been enabled there.
Also, these primitives are from the original SqueakVM branch (interpreter), so there should be problems as well if the primitives are missing.

Levente

On Fri, 16 Mar 2018, Eliot Miranda wrote:

Hi Levente,
   no need for any action on your part.  I see that the Serial Port primitives are essentially unimplemented on Mac OS so it is trivial to provide null implementations for the "ByName" ones.

Last time I talked with the people using the SerialPort plugin they said on Mac they use the linux plugin since the Mac plugin is not implemented, the linux plugin is, and the linux plugin works on all unix systems including Mac.

 

On Fri, Mar 16, 2018 at 3:46 PM, Eliot Miranda <[hidden email]> wrote:
      Hi Levente,
    when I try and build on Mac OS X I get this:

  "_serialPortOpenByName", referenced from:
      _primitiveSerialPortOpenByName in SerialPlugin.lib(SerialPlugin.o)
  "_serialPortReadIntoByName", referenced from:
      _primitiveSerialPortReadByName in SerialPlugin.lib(SerialPlugin.o)
  "_serialPortWriteFromByName", referenced from:
      _primitiveSerialPortWriteByName in SerialPlugin.lib(SerialPlugin.o)

The implementations are missing in both platforms/Mac OS/plugins/SerialPlugin/sqMacSerialPort.c and platforms/iOS/plugins/SerialPlugin/sqMacSerialPort.c.  They are there in
platforms/unix/plugins/SerialPlugin/sqUnixSerial.c and platforms/win32/plugins/SerialPlugin/sqWin32SerialPort.c.

:-(


On Sat, Mar 10, 2018 at 1:58 PM, <[hidden email]> wrote:

      Levente Uzonyi uploaded a new version of VMMaker to project VM Maker:
      http://source.squeak.org/VMMaker/VMMaker.oscog-ul.2354.mcz

      ==================== Summary ====================

      Name: VMMaker.oscog-ul.2354
      Author: ul
      Time: 10 March 2018, 10:56:45.349653 pm
      UUID: b8f3192d-2b33-4a5d-83f9-785fbefbc570
      Ancestors: VMMaker.oscog-eem.2353

      Restored SerialPlugin's *byName* primitives on non-PharoVM VMs.

      =============== Diff against VMMaker.oscog-eem.2353 ===============

      Item was changed:
        ----- Method: SerialPlugin>>primitiveSerialPortOpenByName:baudRate:stopBitsType:parityType:dataBits:inFlowControlType:outFlowControlType:xOnByte:xOffByte: (in category 'primitives') -----
        primitiveSerialPortOpenByName: portName baudRate: baudRate stopBitsType: stopBitsType parityType: parityType dataBits: dataBits inFlowControlType: inFlowControl outFlowControlType:
      outFlowControl xOnByte: xOnChar xOffByte: xOffChar
      -       <option: #PharoVM>
              <var: #port type: 'char *'>

              | port portNameSize |

              self primitive: 'primitiveSerialPortOpenByName'
                      parameters: #(String SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger ).

              portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
              port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
              self cCode: 'memcpy(port, portName, portNameSize)'.

              self cCode: 'serialPortOpenByName(
                              port, baudRate, stopBitsType, parityType, dataBits,
                              inFlowControl, outFlowControl, xOnChar, xOffChar)'.

              self free: port.!

      Item was changed:
        ----- Method: SerialPlugin>>primitiveSerialPortReadByName:into:startingAt:count: (in category 'primitives') -----
        primitiveSerialPortReadByName: portName into: array startingAt: startIndex count: count
      -       <option: #PharoVM>
              <var: #port type: 'char *'>

              | port portNameSize bytesRead arrayPtr |

              self primitive: 'primitiveSerialPortReadByName'
                      parameters: #(String  ByteArray SmallInteger SmallInteger ).

              interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
              "adjust for zero-origin indexing"

              portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
              port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
              self cCode: 'memcpy(port, portName, portNameSize)'.

              arrayPtr := array + startIndex - 1.
              bytesRead := self cCode: 'serialPortReadIntoByName( port, count, arrayPtr)'.

              self free: port.

              ^ bytesRead asSmallIntegerObj!

      Item was changed:
        ----- Method: SerialPlugin>>primitiveSerialPortWriteByName:from:startingAt:count: (in category 'primitives') -----
        primitiveSerialPortWriteByName: portName from: array startingAt: startIndex count: count
      -       <option: #PharoVM>
              <var: #port type: 'char *'>

              | bytesWritten arrayPtr portNameSize port |

              self primitive: 'primitiveSerialPortWriteByName'
                      parameters: #(String ByteArray SmallInteger SmallInteger ).

              portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
              port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
              self cCode: 'memcpy(port, portName, portNameSize)'.

              interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
              interpreterProxy failed
                      ifFalse: [arrayPtr := array + startIndex - 1.
                              bytesWritten := self cCode: 'serialPortWriteFromByName(port, count, arrayPtr)' ].

              self free: port.

              ^ bytesWritten asSmallIntegerObj!




--
_,,,^..^,,,_
best, Eliot




--
_,,,^..^,,,_
best, Eliot





-- 





--
   
Guille Polito
Research Engineer


Centre de Recherche en Informatique, Signal et Automatique de Lille
CRIStAL - UMR 9189
French National Center for Scientific Research - http://www.cnrs.fr

Phone: +33 06 52 70 66 13

Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker.oscog-ul.2354.mcz

Eliot Miranda-2
 
Hi Javier,

On Sun, Mar 18, 2018 at 7:50 AM, Javier Diaz-Reinoso <[hidden email]> wrote:
 
I am not sure if the code of MacOS for "support arbitrary serial speeds" is valid in Linux, the code in pyserial (https://github.com/pyserial/pyserial/blob/master/serial/serialposix.py) is:

elif plat[:6] == 'darwin': # OS X
import array
IOSSIOSPEED = 0x80045402 # _IOW('T', 2, speed_t)
class PlatformSpecific(PlatformSpecificBase):
osx_version = os.uname()[2].split('.')
# Tiger or above can support arbitrary serial speeds
if int(osx_version[0]) >= 8:
def _set_special_baudrate(self, baudrate):
# use IOKit-specific call to set up high speeds
buf = array.array('i', [baudrate])
fcntl.ioctl(self.fd, IOSSIOSPEED, buf, 1)

can the equivalent in C work in linux or the other unix?.

It should be able to, right?  It's just an ioctl.  Can you try and see and commit the results to opensmalltalk/vm, e.g. as a pull request?
 

At the moment I only use SqPronterface in mac (MacBook Pro or iBook G4) connected to an Arduino Mega controlling a Prusa  Mendel printer.


On 18 Mar 2018, at 05:29, Guillermo Polito <[hidden email]> wrote:

Hi,

I've seen also some hiccups with that. I had students that could not use serial port on mac to connect to arduinos and they had to default to a linux virtual box or similar to work... :/

If there is an easy way to replace the "unimplemented" serial port by the unix one without duplicating the code that would be already an improvement by large and I would reaaaally be greatful. Then if there are bugs with reading speed, fixing one would suffice to fix both :).

I can offer myself to test on osx arduinos and maybe connecting to an xbox controller.

Tx!
Guille

On Sat, Mar 17, 2018 at 7:03 PM, Javier Diaz-Reinoso <[hidden email]> wrote:
 
Yes that is right, you can use sqUnixSerial.c instead of the sqMacSerialPort.c but there are limitation about the maximum speed, I have a hacked version of sqUnixSerial.c using the the same way that pyserial use, using this file my program sqPronterface works well at 250000 bps in intel mac, and a maximum of  230400 bps in ppc mac:




On 17 Mar 2018, at 03:02, Clément Bera <[hidden email]> wrote:



On Sat, Mar 17, 2018 at 1:09 AM, Levente Uzonyi <[hidden email]> wrote:
 
Hi Eliot,

I wonder how the Pharo builds handle those. Because these have always been enabled there.
Also, these primitives are from the original SqueakVM branch (interpreter), so there should be problems as well if the primitives are missing.

Levente

On Fri, 16 Mar 2018, Eliot Miranda wrote:

Hi Levente,
   no need for any action on your part.  I see that the Serial Port primitives are essentially unimplemented on Mac OS so it is trivial to provide null implementations for the "ByName" ones.

Last time I talked with the people using the SerialPort plugin they said on Mac they use the linux plugin since the Mac plugin is not implemented, the linux plugin is, and the linux plugin works on all unix systems including Mac.

 

On Fri, Mar 16, 2018 at 3:46 PM, Eliot Miranda <[hidden email]> wrote:
      Hi Levente,
    when I try and build on Mac OS X I get this:

  "_serialPortOpenByName", referenced from:
      _primitiveSerialPortOpenByName in SerialPlugin.lib(SerialPlugin.o)
  "_serialPortReadIntoByName", referenced from:
      _primitiveSerialPortReadByName in SerialPlugin.lib(SerialPlugin.o)
  "_serialPortWriteFromByName", referenced from:
      _primitiveSerialPortWriteByName in SerialPlugin.lib(SerialPlugin.o)

The implementations are missing in both platforms/Mac OS/plugins/SerialPlugin/sqMacSerialPort.c and platforms/iOS/plugins/SerialPlugin/sqMacSerialPort.c.  They are there in
platforms/unix/plugins/SerialPlugin/sqUnixSerial.c and platforms/win32/plugins/SerialPlugin/sqWin32SerialPort.c.

:-(


On Sat, Mar 10, 2018 at 1:58 PM, <[hidden email]> wrote:

      Levente Uzonyi uploaded a new version of VMMaker to project VM Maker:
      http://source.squeak.org/VMMaker/VMMaker.oscog-ul.2354.mcz

      ==================== Summary ====================

      Name: VMMaker.oscog-ul.2354
      Author: ul
      Time: 10 March 2018, 10:56:45.349653 pm
      UUID: b8f3192d-2b33-4a5d-83f9-785fbefbc570
      Ancestors: VMMaker.oscog-eem.2353

      Restored SerialPlugin's *byName* primitives on non-PharoVM VMs.

      =============== Diff against VMMaker.oscog-eem.2353 ===============

      Item was changed:
        ----- Method: SerialPlugin>>primitiveSerialPortOpenByName:baudRate:stopBitsType:parityType:dataBits:inFlowControlType:outFlowControlType:xOnByte:xOffByte: (in category 'primitives') -----
        primitiveSerialPortOpenByName: portName baudRate: baudRate stopBitsType: stopBitsType parityType: parityType dataBits: dataBits inFlowControlType: inFlowControl outFlowControlType:
      outFlowControl xOnByte: xOnChar xOffByte: xOffChar
      -       <option: #PharoVM>
              <var: #port type: 'char *'>

              | port portNameSize |

              self primitive: 'primitiveSerialPortOpenByName'
                      parameters: #(String SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger SmallInteger ).

              portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
              port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
              self cCode: 'memcpy(port, portName, portNameSize)'.

              self cCode: 'serialPortOpenByName(
                              port, baudRate, stopBitsType, parityType, dataBits,
                              inFlowControl, outFlowControl, xOnChar, xOffChar)'.

              self free: port.!

      Item was changed:
        ----- Method: SerialPlugin>>primitiveSerialPortReadByName:into:startingAt:count: (in category 'primitives') -----
        primitiveSerialPortReadByName: portName into: array startingAt: startIndex count: count
      -       <option: #PharoVM>
              <var: #port type: 'char *'>

              | port portNameSize bytesRead arrayPtr |

              self primitive: 'primitiveSerialPortReadByName'
                      parameters: #(String  ByteArray SmallInteger SmallInteger ).

              interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
              "adjust for zero-origin indexing"

              portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
              port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
              self cCode: 'memcpy(port, portName, portNameSize)'.

              arrayPtr := array + startIndex - 1.
              bytesRead := self cCode: 'serialPortReadIntoByName( port, count, arrayPtr)'.

              self free: port.

              ^ bytesRead asSmallIntegerObj!

      Item was changed:
        ----- Method: SerialPlugin>>primitiveSerialPortWriteByName:from:startingAt:count: (in category 'primitives') -----
        primitiveSerialPortWriteByName: portName from: array startingAt: startIndex count: count
      -       <option: #PharoVM>
              <var: #port type: 'char *'>

              | bytesWritten arrayPtr portNameSize port |

              self primitive: 'primitiveSerialPortWriteByName'
                      parameters: #(String ByteArray SmallInteger SmallInteger ).

              portNameSize := interpreterProxy slotSizeOf: (portName asOop: String).
              port := self cCode: 'calloc(portNameSize+1, sizeof(char))'.
              self cCode: 'memcpy(port, portName, portNameSize)'.

              interpreterProxy success: (startIndex >= 1 and: [startIndex + count - 1 <= (interpreterProxy byteSizeOf: array cPtrAsOop)]).
              interpreterProxy failed
                      ifFalse: [arrayPtr := array + startIndex - 1.
                              bytesWritten := self cCode: 'serialPortWriteFromByName(port, count, arrayPtr)' ].

              self free: port.

              ^ bytesWritten asSmallIntegerObj!




--
_,,,^..^,,,_
best, Eliot




--
_,,,^..^,,,_
best, Eliot





-- 





--
   
Guille Polito
Research Engineer


Centre de Recherche en Informatique, Signal et Automatique de Lille
CRIStAL - UMR 9189
French National Center for Scientific Research - http://www.cnrs.fr

Phone: <a href="tel:+33%206%2052%2070%2066%2013" value="+33652706613" target="_blank">+33 06 52 70 66 13





--
_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker.oscog-ul.2354.mcz

Javier Diaz-Reinoso
 
I find this in Stackoverflow :


for linux there are a solution using ioctl, but is very different to MacOS:

I accomplished this using termios2 and ioctl() commands.

struct termios2 options;
ioctl(fd, TCGETS2, &options);
options.c_cflag &= ~CBAUD;    //Remove current BAUD rate
options.c_cflag |= BOTHER;    //Allow custom BAUD rate using int input
options.c_ispeed = 307200;    //Set the input BAUD rate
options.c_ospeed = 307200;    //Set the output BAUD rate
ioctl(fd, TCSETS2, &options);

After that, you should be able to query the port settings and see your custom BAUD rate, as well as the other settings (possible with stty commands).


so ioctl is the same, but the "low level functions" who are called are different, for BSD appears to be similar to MacOS, but because of the differences  I think is better if each plugin file is different.

On 20 Mar 2018, at 12:43, Eliot Miranda <[hidden email]> wrote:

Hi Javier,

On Sun, Mar 18, 2018 at 7:50 AM, Javier Diaz-Reinoso <[hidden email]> wrote:
 
I am not sure if the code of MacOS for "support arbitrary serial speeds" is valid in Linux, the code in pyserial (https://github.com/pyserial/pyserial/blob/master/serial/serialposix.py) is:

elif plat[:6] == 'darwin': # OS X
import array
IOSSIOSPEED = 0x80045402 # _IOW('T', 2, speed_t)
class PlatformSpecific(PlatformSpecificBase):
osx_version = os.uname()[2].split('.')
# Tiger or above can support arbitrary serial speeds
if int(osx_version[0]) >= 8:
def _set_special_baudrate(self, baudrate):
# use IOKit-specific call to set up high speeds
buf = array.array('i', [baudrate])
fcntl.ioctl(self.fd, IOSSIOSPEED, buf, 1)

can the equivalent in C work in linux or the other unix?.

It should be able to, right?  It's just an ioctl.  Can you try and see and commit the results to opensmalltalk/vm, e.g. as a pull request?
 

At the moment I only use SqPronterface in mac (MacBook Pro or iBook G4) connected to an Arduino Mega controlling a Prusa  Mendel printer.

[..cut]
_,,,^..^,,,_
best, Eliot