defining external structrures with bitfields

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

defining external structrures with bitfields

John Whittaker
I'm a relative newbie to Smalltalk and Dolphin.

I am attempting to create an external structure class to mirror the Win32
DCB structure.  This structure has a number of bitfields.  How does one
define a Dolphin external structure which has bitfields?

Thanks for any help.


FYI, here is the C structure declaration for DCB:

The DCB structure defines the control setting for a serial communications
device.
typedef struct _DCB { // dcb
    DWORD DCBlength;           // sizeof(DCB)
    DWORD BaudRate;            // current baud rate
    DWORD fBinary: 1;          // binary mode, no EOF check
    DWORD fParity: 1;          // enable parity checking
    DWORD fOutxCtsFlow:1;      // CTS output flow control
    DWORD fOutxDsrFlow:1;      // DSR output flow control
    DWORD fDtrControl:2;       // DTR flow control type
    DWORD fDsrSensitivity:1;   // DSR sensitivity
    DWORD fTXContinueOnXoff:1; // XOFF continues Tx
    DWORD fOutX: 1;            // XON/XOFF out flow control
    DWORD fInX: 1;             // XON/XOFF in flow control
    DWORD fErrorChar: 1;       // enable error replacement
    DWORD fNull: 1;            // enable null stripping
    DWORD fRtsControl:2;       // RTS flow control
    DWORD fAbortOnError:1;     // abort reads/writes on error
    DWORD fDummy2:17;          // reserved
    WORD wReserved;            // not currently used
    WORD XonLim;               // transmit XON threshold
    WORD XoffLim;              // transmit XOFF threshold
    BYTE ByteSize;             // number of bits/byte, 4-8
    BYTE Parity;               // 0-4=no,odd,even,mark,space
    BYTE StopBits;             // 0,1,2 = 1, 1.5, 2
    char XonChar;              // Tx and Rx XON character
    char XoffChar;             // Tx and Rx XOFF character
    char ErrorChar;            // error replacement character
    char EofChar;              // end of input character
    char EvtChar;              // received event character
    WORD wReserved1;           // reserved; do not use
} DCB;


Reply | Threaded
Open this post in threaded view
|

Re: defining external structrures with bitfields

Chris Double-2
Hello John, fancy meeting you here :).

> I am attempting to create an external structure class to mirror the
> Win32 DCB structure.  This structure has a number of bitfields.  How
> does one define a Dolphin external structure which has bitfields?

According to the documentation:

http://www.object-arts.com/EducationCentre/Overviews/ExternalInterfacing.htm

  Accessors for bit fields will have to be hand coded
  (e.g. _FPIEEE_RECORD). These are rather uncommon, so automated
  support is considered a low priority."


Even better though is a goodie that already has it along with other
serial communications stuff defined:

  http://www.iandb.org.uk/goodies4/serial.htm


Chris 'Trying out Dolphin too' Double.
--
http://www.double.co.nz/smalltalk


Reply | Threaded
Open this post in threaded view
|

Re: defining external structrures with bitfields

Ian Bartholomew-3
John,

If you do decide to implement DCB yourself then make sure you add the
following class method. Because DCB is an old, original, Windows structure
it is aligned on Byte boundaries and Dolphin needs to be told.

packing
    ^1

Ian