Testing ExtendedSerialPort on Linux

John M McIntosh johnmci at smalltalkconsulting.com
Fri Jun 10 01:21:07 UTC 2005


22?
#define EINVAL          22              /* Invalid argument */

These can be found in the errno.h file on your system, or in a man  
page (which is?)


Ssince the termios has a different structure, you must review the
SerialPortTermios class and create a subclass for Linux.

So for example
cispeed: aUnsignedLong
     ^self putLong: aUnsignedLong at: self cispeedOffset.

cispeedOffset   "Which is 4 * 4 bytes given the BSD structure "
     ^16+self nccs

but nccs is only defined in
SerialPortTermiosOSX as 20


This is the BSD structure
struct termios {
         tcflag_t        c_iflag;        /* input flags */
         tcflag_t        c_oflag;        /* output flags */
         tcflag_t        c_cflag;        /* control flags */
         tcflag_t        c_lflag;        /* local flags */
         cc_t            c_cc[NCCS];     /* control chars */
         speed_t         c_ispeed;       /* input speed */
         speed_t         c_ospeed;       /* output speed */
};

Since Linux has the extra  cc_t c_line;     /* line discipline */  
unless you've already changed the offset you will poke/extract data  
incorrectly into the
termios structure.

I'll note someone in the past suggested recoding the logic to make  
primitives to return the offsets, and the constants, thus ensuring  
this will work
on other unix systems with less effort. Also that would support  
perhaps 64bit unix systems with less effort.



On 9-Jun-05, at 12:08 PM, Samir Saidani wrote:

>
> Ok, I corrected the structureSize :
>
> For linux :
>
> struct termios
>   {
>     tcflag_t c_iflag;           /* input mode flags */
>     tcflag_t c_oflag;           /* output mode flags */
>     tcflag_t c_cflag;           /* control mode flags */
>     tcflag_t c_lflag;           /* local mode flags */
>     cc_t c_line;                        /* line discipline */
>     cc_t c_cc[NCCS];            /* control characters */
>     speed_t c_ispeed;           /* input speed */
>     speed_t c_ospeed;           /* output speed */
>   };
>
> Does it have an impact on the definition of the other classes ?
> I have no error on tcgetattr, but now I get an error on this method
> setispeed: aNumber
>     | error |
>     error := self primitiveSerialPortUnixCfsetispeed: self  
> workingSerialTermios speed: aNumber.
>     error isZero
>         ifFalse: [SerialPortExtendedError signal: error
>                 asString]
>
> with the signal error : 22
>
> Do you have any idea of what is wrong now ?
>
> Thank you very much to help me to debug this stuff, John !
>
>
>
> John M McIntosh <johnmci at smalltalkconsulting.com> writes:
>
>
>> On Jun 9, 2005, at 10:13 AM, Samir Saidani wrote:
>>
>>
>>>
>>> Ok done, but it seems that my first guess was wrong, the  
>>> tcgetattr is
>>> not involved into the problem...
>>> This part fails
>>>  if (!((sizeOftermios()) == (interpreterProxy-
>>>
>>>> sizeOfSTArrayFromCPrimitive(atermios)))) {
>>>>
>>>                 interpreterProxy->primitiveFail();
>>>                 return null;
>>>         }
>>>
>>> and the value of sizeOftermios is 40 whereas the other gives
>>> 60... what means sizeOfSTArrayFromCPrimitive(atermios) ? Is it maybe
>>> related to the problem of char* ?
>>>
>>> Samir
>>>
>>
>> This means the os-x/FreeBSD/OpenBSD Termios is different size and
>> structure that your Linux version,
>> sizeOfSTArrayFromCPrimitive gets the size of the bytearray that is
>> being passed in. This means the
>> SerialPortTermios class is not setting the right size of the  
>> bytearray.
>>
>> See the class comments in SerialPortTermios and SerialPortTermiosOSX
>> class>>stuctureSize
>>
>> See
>> SerialPortExtended>defaultExtendedSession
>> to decide how to instantiate your custom  extended session class.
>>
>> Also see
>> SerialPortExtendedSessionUnix>>defaultTermiosClass
>>
>> This is the BSD structure
>> struct termios {
>>          tcflag_t        c_iflag;        /* input flags */
>>          tcflag_t        c_oflag;        /* output flags */
>>          tcflag_t        c_cflag;        /* control flags */
>>          tcflag_t        c_lflag;        /* local flags */
>>          cc_t            c_cc[NCCS];     /* control chars */
>>          speed_t         c_ispeed;       /* input speed */
>>          speed_t         c_ospeed;       /* output speed */
>> };
>>
>> see
>> www.opengroup.org/onlinepubs/ 007908799/xsh/termios.h.html
>> & of course you  need to understand the termios structure your unix
>> system is using.
>>
>> --
>> ===================================================================== 
>> ===
>> ===
>> John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
>> Corporate Smalltalk Consulting Ltd.  http:// 
>> www.smalltalkconsulting.com
>> ===================================================================== 
>> ===
>> ===
>>
>>
>>
>>
>
> -- 
> Samir SAIDANI
> PhD Student in CS / Doctorant en informatique     web : http:// 
> www.info.unicaen.fr/~saidani
> Universite de Caen - Laboratoire GREYC          tel : 02-31-56-74-30
> Equipe MAD - Campus II - 14032 Caen Cedex       fax : 02-31-56-76-30
>
>
>

--
======================================================================== 
===
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
======================================================================== 
===




More information about the Squeak-dev mailing list