Testing ExtendedSerialPort on Linux

John M McIntosh johnmci at smalltalkconsulting.com
Fri Jun 10 18:32:28 UTC 2005


On 10-Jun-05, at 6:29 AM, Samir Saidani wrote:

>
> I have in bits/termios.h
>
>
> What stuck me is that ncss for SerialPortTermiosOSX is 20 (hex) which

No it's 20 bytes, if you want to express things in Smalltalk in base  
16 (hex) you would
say 16rAF   where number before r is base, and [0-9][A-Z] for  
digits.   another 17rAG  base 17. (186 decimal).

16r20 is 32 decimal, just inspect it.
We'll also assume here that tcflag_t, cc_t, speed_t all typedef to 4  
byte integer.


> is 32, and structureSize is 4 + 4 + 4 + 4 + 20 + 4 + 4, but if I kept
> the hex form for SerialPortTermiosUnix, it doesn't work, which seems
> to mean that the value are in decimal and not hex. But anyway, with
> ncss at 20 or 32, it doesn't work, same 22 error. But if I replace 32
> by 20 in structureSize, the primitive failed due to the problem we
> discussed earlier (60 vs 48)...

So if you get the printString of your workingSerialTermios  what does  
it look like?

Given the C code is this  are you saying the error (#22 EINVAL)  
occurs at the cfsetispeed.
check your man cfsetispeed and see if there are any clues.
I also believe you have to open the fd before you can set the speed,  
what is the smalltalk you
are using to get to the point of failure?


EXPORT(sqInt) primitiveSerialPortUnixCfsetispeed(void) {
     sqInt error;
     sqInt speed;
     char *atermios;
     sqInt aNumber;
     sqInt _return_value;

     interpreterProxy->success(interpreterProxy->isBytes 
(interpreterProxy->stackValue(1)));
     atermios = ((char *) (interpreterProxy->firstIndexableField 
(interpreterProxy->stackValue(1))));
     aNumber = interpreterProxy->stackValue(0);
     if (interpreterProxy->failed()) {
         return null;
     }
     if (!((sizeOftermios()) == (interpreterProxy- 
 >sizeOfSTArrayFromCPrimitive(atermios)))) {
         interpreterProxy->primitiveFail();
         return null;
     }
     speed = interpreterProxy->positive32BitValueOf(aNumber);
     error = cfsetispeed(atermios,speed);
     if (error == -1) {
         error = getError();
     }
     _return_value = interpreterProxy->integerObjectOf(error);
     if (interpreterProxy->failed()) {
         return null;
     }
     interpreterProxy->popthenPush(3, _return_value);
     return null;
}


>
> John, the problem of warning error for the compiler worries me, don't
> like such errors which could have some unknown side effects, and I
> don't understand how it could be possible that functions eating a
> structure could accept a pointer to char, (a kind of implicit cast
> ???) but I must confess that I'm not really fluent with C, and
> probably this remark is revealing some misunderstanding about this
> language.

Yes it is an implicit case, which is why C is so dangerous, it's  
quite capable of converting
any structure to a pointer back to a structure without any care about  
sizing or reality.

>
> Cheers,
> Samir

--
======================================================================== 
===
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