author | Stefan Vogel <sv@exept.de> |
Thu, 04 Feb 2010 12:48:58 +0100 | |
changeset 2423 | f23438963384 |
parent 2419 | 8ea9b41e7b4b |
child 2610 | cb6211751636 |
permissions | -rw-r--r-- |
1593 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
"{ Package: 'stx:libbasic2' }" |
|
13 |
||
14 |
NonPositionableExternalStream subclass:#SerialPort |
|
1595 | 15 |
instanceVariableNames:'portName baudRate stopBitsType parityType dataBits inFlowCtrlType |
16 |
outFlowCtrlType xOnChar xOffChar' |
|
1593 | 17 |
classVariableNames:'DefaultPortName' |
18 |
poolDictionaries:'' |
|
19 |
category:'Streams-External' |
|
20 |
! |
|
21 |
||
22 |
!SerialPort primitiveDefinitions! |
|
23 |
%{ |
|
24 |
||
25 |
#include "stxOSDefs.h" |
|
26 |
||
27 |
#ifdef WIN32 |
|
28 |
||
29 |
# undef __BEGIN_INTERRUPTABLE__ |
|
30 |
# undef __END_INTERRUPTABLE__ |
|
31 |
# define __BEGIN_INTERRUPTABLE__ .. |
|
32 |
# define __END_INTERRUPTABLE__ .. |
|
33 |
||
34 |
# define WRAP_STDIO |
|
35 |
||
36 |
# define PORT_FROM_FD(fd) (_get_osfhandle(fd)) |
|
37 |
# define closePort(port) closeHandle(port) |
|
38 |
# define SERIALPORT HANDLE |
|
39 |
||
40 |
#else /* not WIN32 */ |
|
41 |
||
42 |
# define PORT_FROM_FD(fd) (fd) |
|
43 |
# define closePort(port) close(port) |
|
44 |
# define SERIALPORT int |
|
45 |
||
46 |
#endif /* WIN32 */ |
|
47 |
||
48 |
# define PORT_FROM_FILE(f) (PORT_FROM_FD(fileno(f))) |
|
49 |
# define PORT_FROM_FILE_OBJECT(f) (PORT_FROM_FILE(__FILEVal(f))) |
|
50 |
||
51 |
#include <stdio.h> |
|
52 |
#include <errno.h> |
|
53 |
||
54 |
/* |
|
55 |
* on some systems errno is a macro ... check for it here |
|
56 |
*/ |
|
57 |
#ifndef errno |
|
58 |
extern errno; |
|
59 |
#endif |
|
60 |
||
61 |
#ifdef USE_H_ERRNO |
|
62 |
# ifndef h_errno |
|
63 |
extern h_errno; |
|
64 |
# endif |
|
65 |
#endif |
|
66 |
||
67 |
#ifdef DEBUG |
|
1839 | 68 |
# define DBGPRINTF(x) { if (__debugging__) console_printf x; } |
1593 | 69 |
#else |
70 |
# define DBGPRINTF(x) /* as nothing */ |
|
71 |
#endif |
|
72 |
||
73 |
#ifndef TRUE |
|
74 |
# define TRUE 1 |
|
75 |
#endif |
|
76 |
#ifndef FALSE |
|
77 |
# define FALSE 0 |
|
78 |
#endif |
|
79 |
#ifndef WIN32 |
|
80 |
typedef int BOOL; |
|
81 |
#endif |
|
82 |
||
83 |
||
84 |
%} |
|
85 |
! ! |
|
86 |
||
87 |
!SerialPort primitiveVariables! |
|
88 |
%{ |
|
89 |
static int __debugging__ = 0; |
|
90 |
%} |
|
91 |
! ! |
|
92 |
||
93 |
!SerialPort class methodsFor:'documentation'! |
|
94 |
||
95 |
copyright |
|
96 |
" |
|
97 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
98 |
All Rights Reserved |
|
99 |
||
100 |
This software is furnished under a license and may be used |
|
101 |
only in accordance with the terms of that license and with the |
|
102 |
inclusion of the above copyright notice. This software may not |
|
103 |
be provided or otherwise made available to, or used by, any |
|
104 |
other person. No title to or ownership of the software is |
|
105 |
hereby transferred. |
|
106 |
" |
|
107 |
! |
|
108 |
||
109 |
documentation |
|
110 |
" |
|
1598 | 111 |
This class provides access to serial ports. |
112 |
||
113 |
Arguments/Parameters/Instvars: |
|
114 |
||
115 |
portName String device name |
|
116 |
WIN32: COM0, COM1, ... |
|
117 |
Unix: /dev/cua0, ... |
|
118 |
||
119 |
||
120 |
baudRate Integer 9600, 19200, ... |
|
121 |
stopBitsType Symbol #stop1, #stop1_5 or #stop2 |
|
122 |
parityType Symbol #odd, #even or #none |
|
123 |
dataBits Integer 5, 6, 7, 8 |
|
1599 | 124 |
inFlowCtrlType Symbol #xOnOff, #hardware or #none |
125 |
outFlowCtrlType Symbol #xOnOff, #hardware or #none |
|
1598 | 126 |
xOnChar Integer | Character |
127 |
xOffChar' Integer | Character |
|
1593 | 128 |
" |
129 |
! |
|
130 |
||
131 |
examples |
|
132 |
" |
|
133 |
example (get help info from an nntp server): |
|
1598 | 134 |
[exBegin] |
1595 | 135 |
|serialPort| |
136 |
||
137 |
serialPort := SerialPort new setPortName:(SerialPort defaultPortName). |
|
138 |
serialPort open. |
|
139 |
serialPort close. |
|
1598 | 140 |
[exEnd] |
1596 | 141 |
|
1598 | 142 |
[exBegin] |
1596 | 143 |
|serialPort| |
144 |
||
145 |
serialPort := SerialPort new setPortName:'COM5'. |
|
146 |
serialPort open. |
|
147 |
serialPort nextPutAll:'hello world'. |
|
148 |
serialPort cr. |
|
149 |
serialPort close. |
|
1598 | 150 |
[exEnd] |
1597 | 151 |
|
1598 | 152 |
[exBegin] |
1597 | 153 |
|serialPort| |
154 |
||
155 |
serialPort := SerialPort new setPortName:'COM5'. |
|
156 |
serialPort open. |
|
157 |
Transcript showCR:(serialPort nextAvailable:100). |
|
158 |
serialPort close. |
|
1598 | 159 |
[exEnd] |
1593 | 160 |
" |
161 |
! ! |
|
162 |
||
1595 | 163 |
!SerialPort class methodsFor:'instance creation'! |
1593 | 164 |
|
1595 | 165 |
new |
166 |
"create a serial port" |
|
1593 | 167 |
|
1595 | 168 |
^ super new buffered:false |
169 |
! |
|
1593 | 170 |
|
171 |
portName:portName |
|
172 |
baudRate:baudRateOrNil stopBitsType:stopBitsTypeOrNil |
|
173 |
parityType:parityTypeOrNil dataBits:dataBitsOrNil |
|
174 |
inFlowCtrlType:inFlowCtrlTypeOrNil outFlowCtrlType:outFlowCtrlTypeOrNil |
|
175 |
xOnChar:xOnCharOrNil xOffChar:xOffCharOrNil |
|
176 |
||
177 |
"arguments are self describing; nil values mean: leave setting as is" |
|
178 |
||
1599 | 179 |
^ self new |
1593 | 180 |
setPortName:portName |
181 |
baudRate:baudRateOrNil stopBitsType:stopBitsTypeOrNil |
|
182 |
parityType:parityTypeOrNil dataBits:dataBitsOrNil |
|
183 |
inFlowCtrlType:inFlowCtrlTypeOrNil outFlowCtrlType:outFlowCtrlTypeOrNil |
|
1599 | 184 |
xOnChar:xOnCharOrNil xOffChar:xOffCharOrNil |
1593 | 185 |
! ! |
186 |
||
187 |
!SerialPort class methodsFor:'debugging'! |
|
188 |
||
189 |
debug:aBoolean |
|
190 |
"turn on/off internal debugprints. |
|
191 |
This method is for ST/X debugging only and |
|
192 |
may be removed in later versions" |
|
193 |
||
194 |
%{ /* NOCONTEXT */ |
|
195 |
||
196 |
__debugging__ = (aBoolean == true); |
|
197 |
%} |
|
198 |
" |
|
199 |
SerialPort debug:true |
|
200 |
SerialPort debug:false |
|
201 |
" |
|
202 |
! ! |
|
203 |
||
1595 | 204 |
!SerialPort class methodsFor:'defaults'! |
205 |
||
206 |
defaultPortName |
|
207 |
DefaultPortName notNil ifTrue:[^ DefaultPortName ]. |
|
208 |
||
209 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
1596 | 210 |
^ 'COM0' |
1595 | 211 |
]. |
212 |
^ '/dev/cua0' |
|
213 |
! ! |
|
214 |
||
1593 | 215 |
!SerialPort methodsFor:'accessing'! |
216 |
||
1595 | 217 |
setBaudRate:baudRateOrNil |
218 |
baudRate := baudRateOrNil. |
|
219 |
! |
|
220 |
||
1598 | 221 |
setDataBits:dataBitsOrNil |
222 |
dataBits := dataBitsOrNil. |
|
223 |
! |
|
224 |
||
225 |
setParityType:parityTypeOrNil |
|
226 |
parityType := parityTypeOrNil. |
|
227 |
! |
|
228 |
||
1595 | 229 |
setPortName:portNameArg |
2020
f47ac2710db3
Change port name COM* to \\.\COM* to support com ports > 9
ab
parents:
1903
diff
changeset
|
230 |
(portNameArg startsWith:'C') ifTrue:[ |
2321
6f4cc7b644db
filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents:
2020
diff
changeset
|
231 |
"/ add special port name to support COM ports > 9 |
6f4cc7b644db
filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents:
2020
diff
changeset
|
232 |
portName := '\\.\', portNameArg. |
6f4cc7b644db
filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents:
2020
diff
changeset
|
233 |
^ self |
2020
f47ac2710db3
Change port name COM* to \\.\COM* to support com ports > 9
ab
parents:
1903
diff
changeset
|
234 |
]. |
1595 | 235 |
portName := portNameArg. |
236 |
! |
|
237 |
||
1593 | 238 |
setPortName:portNameArg |
2321
6f4cc7b644db
filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents:
2020
diff
changeset
|
239 |
baudRate:baudRateOrNil stopBitsType:stopBitsTypeOrNil |
6f4cc7b644db
filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents:
2020
diff
changeset
|
240 |
parityType:parityTypeOrNil dataBits:dataBitsOrNil |
6f4cc7b644db
filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents:
2020
diff
changeset
|
241 |
inFlowCtrlType:inFlowCtrlTypeOrNil outFlowCtrlType:outFlowCtrlTypeOrNil |
6f4cc7b644db
filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents:
2020
diff
changeset
|
242 |
xOnChar:xOnCharOrNil xOffChar:xOffCharOrNil |
1593 | 243 |
|
2020
f47ac2710db3
Change port name COM* to \\.\COM* to support com ports > 9
ab
parents:
1903
diff
changeset
|
244 |
self setPortName:portNameArg. |
1593 | 245 |
baudRate := baudRateOrNil. |
246 |
stopBitsType := stopBitsTypeOrNil. |
|
247 |
parityType := parityTypeOrNil. |
|
248 |
dataBits := dataBitsOrNil. |
|
249 |
inFlowCtrlType := inFlowCtrlTypeOrNil. |
|
250 |
outFlowCtrlType := outFlowCtrlTypeOrNil. |
|
251 |
xOnChar := xOnCharOrNil. |
|
252 |
xOffChar := xOffCharOrNil. |
|
1846 | 253 |
! |
254 |
||
255 |
setStopBitsType:stopBitsTypeOrNil |
|
256 |
stopBitsType := stopBitsTypeOrNil. |
|
1593 | 257 |
! ! |
258 |
||
1595 | 259 |
!SerialPort methodsFor:'low level'! |
260 |
||
261 |
baudRate:newRate |
|
2321
6f4cc7b644db
filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents:
2020
diff
changeset
|
262 |
handle isNil ifTrue:[ |
1598 | 263 |
"not open" |
264 |
baudRate := newRate. |
|
265 |
^ self |
|
266 |
]. |
|
1595 | 267 |
%{ |
268 |
OBJ fp; |
|
269 |
||
2321
6f4cc7b644db
filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents:
2020
diff
changeset
|
270 |
fp = __INST(handle); |
1598 | 271 |
if (__isSmallInteger(newRate)) { |
1595 | 272 |
SERIALPORT port; |
273 |
int ret; |
|
274 |
||
275 |
port = PORT_FROM_FILE_OBJECT(fp); |
|
276 |
#ifdef WIN32 |
|
277 |
{ |
|
278 |
DCB dcb; |
|
279 |
||
280 |
ZeroMemory(&dcb, sizeof(dcb)); |
|
281 |
dcb.DCBlength = sizeof(dcb); |
|
282 |
GetCommState(port, &dcb); |
|
283 |
||
284 |
dcb.BaudRate = __intVal(newRate); |
|
285 |
||
286 |
if (! SetCommState(port, &dcb)) { |
|
287 |
RETURN(false); |
|
288 |
} |
|
1598 | 289 |
__INST(baudRate) = newRate; |
1595 | 290 |
RETURN(true); |
291 |
} |
|
292 |
# else /* ! WIN32 */ |
|
293 |
/* add code for unix ioctl here ... */ |
|
294 |
# endif /* WIN32 */ |
|
295 |
} |
|
296 |
%}. |
|
297 |
self primitiveFailed. |
|
298 |
! ! |
|
299 |
||
1593 | 300 |
!SerialPort protectedMethodsFor:'low level'! |
301 |
||
302 |
closeFile |
|
303 |
"low level close" |
|
304 |
||
305 |
%{ |
|
306 |
OBJ t; |
|
307 |
||
2321
6f4cc7b644db
filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents:
2020
diff
changeset
|
308 |
t = __INST(handle); |
1593 | 309 |
if (t != nil) { |
310 |
FILE *fp; |
|
311 |
SERIALPORT port; |
|
312 |
||
2321
6f4cc7b644db
filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents:
2020
diff
changeset
|
313 |
__INST(handle) = nil; |
1593 | 314 |
fp = __FILEVal(t); |
315 |
port = PORT_FROM_FILE(fp); |
|
316 |
||
317 |
# ifdef xxDO_WRAP_CALLS |
|
318 |
{ int ret; |
|
319 |
||
320 |
do { |
|
321 |
__threadErrno = 0; |
|
322 |
ret = STX_C_CALL1("fclose", fclose, fp); |
|
323 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
|
324 |
||
325 |
# ifdef WIN32 |
|
326 |
do { |
|
327 |
__threadErrno = 0; |
|
328 |
ret = STX_WSA_CALL1("CloseHandle", CloseHandle, port); |
|
329 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
|
330 |
CloseHandle(port); |
|
331 |
# endif |
|
332 |
} |
|
333 |
# else /* !DO_WRAP_CALLS */ |
|
334 |
||
335 |
fclose(fp); |
|
336 |
# ifdef WIN32 |
|
337 |
CloseHandle(port); |
|
338 |
# endif |
|
339 |
||
340 |
# endif /* !DO_WRAP_CALLS */ |
|
341 |
} |
|
342 |
%} |
|
343 |
! ! |
|
344 |
||
345 |
!SerialPort methodsFor:'opening'! |
|
346 |
||
347 |
open |
|
1596 | 348 |
|errorSymbol errorNumber| |
1593 | 349 |
|
2321
6f4cc7b644db
filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents:
2020
diff
changeset
|
350 |
handle notNil ifTrue:[ |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
351 |
^ self errorAlreadyOpen |
1593 | 352 |
]. |
353 |
%{ |
|
354 |
FILE *fp; |
|
355 |
SERIALPORT port; |
|
356 |
char *__portName; |
|
357 |
int __setBaudRate = 1, |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
358 |
__setDataBits = 1, |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
359 |
__setXOnChar = 1, |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
360 |
__setXOffChar = 1, |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
361 |
__setInFlowCtrl = 1, |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
362 |
__setOutFlowCtrl = 1, |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
363 |
__setStopBits = 1, |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
364 |
__setParityType = 1; |
1593 | 365 |
int __baudRate, __dataBits; |
366 |
int __xOnChar, __xOffChar; |
|
367 |
int __inFlowCtrl, __outFlowCtrl; |
|
368 |
int __stopBits, __parityType; |
|
369 |
#ifdef WIN32 |
|
370 |
COMMTIMEOUTS timeouts; |
|
371 |
DCB dcb; |
|
372 |
#endif /* WIN32 */ |
|
373 |
||
1599 | 374 |
# define FLOW_XONOFF 1 |
375 |
# define FLOW_HARDWARE 2 |
|
376 |
# define FLOW_NONE 3 |
|
377 |
# define STOP_1 1 |
|
378 |
# define STOP_2 2 |
|
379 |
# define STOP_1_5 3 |
|
380 |
# define PARITY_ODD 1 |
|
381 |
# define PARITY_EVEN 2 |
|
382 |
# define PARITY_NONE 3 |
|
1593 | 383 |
|
384 |
if (__isString(__INST(portName))) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
385 |
__portName = __stringVal(__INST(portName)); |
1593 | 386 |
} else { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
387 |
errorSymbol = @symbol(portName); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
388 |
goto getOutOfhere; |
1593 | 389 |
} |
390 |
||
391 |
if (__isSmallInteger(__INST(baudRate))) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
392 |
__baudRate = __intVal(__INST(baudRate)); |
1593 | 393 |
} else if (__INST(baudRate) == nil) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
394 |
__setBaudRate = 0; |
1593 | 395 |
} else { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
396 |
errorSymbol = @symbol(baudRate); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
397 |
goto getOutOfhere; |
1593 | 398 |
} |
399 |
||
400 |
if (__isSmallInteger(__INST(dataBits))) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
401 |
__dataBits = __intVal(__INST(dataBits)); |
1596 | 402 |
} else if (__INST(dataBits) == nil) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
403 |
__setDataBits = 0; |
1593 | 404 |
} else { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
405 |
errorSymbol = @symbol(dataBits); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
406 |
goto getOutOfhere; |
1593 | 407 |
} |
408 |
||
409 |
if (__isSmallInteger(__INST(xOnChar))) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
410 |
__xOnChar = __intVal(__INST(xOnChar)); |
1593 | 411 |
} else if (__isCharacter(__INST(xOnChar))) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
412 |
__xOnChar = __intVal(_characterVal(__INST(xOnChar))); |
1593 | 413 |
} else if (__INST(xOnChar) == nil) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
414 |
__setXOnChar = 0; |
1593 | 415 |
} else { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
416 |
errorSymbol = @symbol(xOnChar); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
417 |
goto getOutOfhere; |
1593 | 418 |
} |
419 |
||
420 |
if (__isSmallInteger(__INST(xOffChar))) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
421 |
__xOffChar = __intVal(__INST(xOffChar)); |
1593 | 422 |
} else if (__isCharacter(__INST(xOffChar))) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
423 |
__xOffChar = __intVal(__characterVal(__INST(xOffChar))); |
1593 | 424 |
} else if (__INST(xOffChar) == nil) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
425 |
__setXOffChar = 0; |
1593 | 426 |
} else { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
427 |
errorSymbol = @symbol(xOffChar); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
428 |
goto getOutOfhere; |
1593 | 429 |
} |
430 |
||
431 |
if (__INST(inFlowCtrlType) == @symbol(xOnOff)) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
432 |
__inFlowCtrl = FLOW_XONOFF; |
1593 | 433 |
} else if (__INST(inFlowCtrlType) == @symbol(hardware)) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
434 |
__inFlowCtrl = FLOW_HARDWARE; |
1599 | 435 |
} else if (__INST(inFlowCtrlType) == @symbol(none)) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
436 |
__inFlowCtrl = FLOW_NONE; |
1593 | 437 |
} else if (__INST(inFlowCtrlType) == nil) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
438 |
__setInFlowCtrl = 0; |
1593 | 439 |
} else { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
440 |
errorSymbol = @symbol(inFlowCtrlType); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
441 |
goto getOutOfhere; |
1593 | 442 |
} |
443 |
||
444 |
if (__INST(outFlowCtrlType) == @symbol(xOnOff)) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
445 |
__outFlowCtrl = FLOW_XONOFF; |
1593 | 446 |
} else if (__INST(outFlowCtrlType) == @symbol(hardware)) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
447 |
__outFlowCtrl = FLOW_HARDWARE; |
1599 | 448 |
} else if (__INST(outFlowCtrlType) == @symbol(none)) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
449 |
__outFlowCtrl = FLOW_NONE; |
1593 | 450 |
} else if (__INST(outFlowCtrlType) == nil) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
451 |
__setOutFlowCtrl = 0; |
1593 | 452 |
} else { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
453 |
errorSymbol = @symbol(outFlowCtrlType); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
454 |
goto getOutOfhere; |
1593 | 455 |
} |
456 |
||
457 |
if (__INST(stopBitsType) == @symbol(stop1)) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
458 |
__stopBits = STOP_1; |
1593 | 459 |
} else if (__INST(stopBitsType) == @symbol(stop2)) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
460 |
__stopBits = STOP_2; |
1593 | 461 |
} else if (__INST(stopBitsType) == @symbol(stop1_5)) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
462 |
__stopBits = STOP_1_5; |
1593 | 463 |
} else if (__INST(stopBitsType) == nil) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
464 |
__setStopBits = 0; |
1593 | 465 |
} else { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
466 |
errorSymbol = @symbol(stopBitsType); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
467 |
goto getOutOfhere; |
1596 | 468 |
} |
469 |
||
470 |
if (__INST(parityType) == @symbol(odd)) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
471 |
__parityType = PARITY_ODD; |
1596 | 472 |
} else if (__INST(parityType) == @symbol(even)) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
473 |
__parityType = PARITY_EVEN; |
1596 | 474 |
} else if (__INST(parityType) == @symbol(none)) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
475 |
__parityType = PARITY_NONE; |
1596 | 476 |
} else if (__INST(parityType) == nil) { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
477 |
__setParityType = 0; |
1596 | 478 |
} else { |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
479 |
errorSymbol = @symbol(parityType); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
480 |
goto getOutOfhere; |
1593 | 481 |
} |
482 |
||
483 |
#ifdef WIN32 |
|
484 |
port = CreateFile(__portName, |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
485 |
GENERIC_READ | GENERIC_WRITE, |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
486 |
0, /* comm devices must be opened with exclusive access */ |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
487 |
NULL, /* no security attrs */ |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
488 |
OPEN_EXISTING, /* comm devices must use OPEN_EXISTING */ |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
489 |
0, /* no overlapped I/O */ |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
490 |
NULL /* hTemplate must be NULL for comm devices */ |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
491 |
); |
1593 | 492 |
|
493 |
if (port == INVALID_HANDLE_VALUE) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
494 |
console_fprintf(stderr, "Win32OS [info]: serial port open failed\n"); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
495 |
errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) ); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
496 |
errorSymbol = @symbol(openFailed); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
497 |
goto getOutOfhere; |
1593 | 498 |
} |
499 |
||
500 |
/* Flush the driver */ |
|
501 |
PurgeComm( port, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR ); |
|
502 |
||
503 |
/* Set driver buffer sizes */ |
|
504 |
SetupComm( port, 4096 /*SERIAL_IN_QUEUE_SIZE*/, 4096 /*SERIAL_OUT_QUEUE_SIZE*/); |
|
505 |
||
506 |
/* Reset timeout constants */ |
|
507 |
timeouts.ReadIntervalTimeout= 0xFFFFFFFF; |
|
508 |
timeouts.ReadTotalTimeoutMultiplier = 0; |
|
509 |
timeouts.ReadTotalTimeoutConstant = 0; |
|
510 |
timeouts.WriteTotalTimeoutMultiplier = 0; |
|
511 |
timeouts.WriteTotalTimeoutConstant = 0; |
|
512 |
SetCommTimeouts( port, &timeouts ); |
|
513 |
||
514 |
/* Set communication parameters */ |
|
515 |
ZeroMemory(&dcb, sizeof(dcb)); |
|
516 |
dcb.DCBlength = sizeof(dcb); |
|
517 |
GetCommState(port, &dcb); |
|
518 |
||
519 |
if (__setBaudRate) dcb.BaudRate = __baudRate; |
|
520 |
if (__setDataBits) dcb.ByteSize = __dataBits; |
|
521 |
if (__setXOnChar) dcb.XonChar = __xOnChar; |
|
522 |
if (__setXOffChar) dcb.XoffChar = __xOffChar; |
|
523 |
||
524 |
if (__setStopBits) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
525 |
/* set stop bits */ |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
526 |
switch(__stopBits) { |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
527 |
case STOP_1_5: dcb.StopBits = 1; break; /* 1.5 stop bits */ |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
528 |
case STOP_1: dcb.StopBits = 0; break; /* 1 stop bit */ |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
529 |
case STOP_2: dcb.StopBits = 2; break; /* 2 stop bits */ |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
530 |
default: |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
531 |
errorSymbol = @symbol(stopBits); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
532 |
goto errExit; |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
533 |
} |
1593 | 534 |
} |
535 |
||
536 |
if (__setParityType) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
537 |
/* set parity */ |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
538 |
switch(__parityType) { |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
539 |
case PARITY_NONE: dcb.Parity = NOPARITY; break; |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
540 |
case PARITY_ODD: dcb.Parity = ODDPARITY; break; |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
541 |
case PARITY_EVEN: dcb.Parity = EVENPARITY; break; |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
542 |
default: |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
543 |
errorSymbol = @symbol(parityType); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
544 |
goto errExit; |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
545 |
} |
1593 | 546 |
} |
547 |
||
548 |
if (__setInFlowCtrl) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
549 |
/* set control flow */ |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
550 |
dcb.fInX = FALSE; |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
551 |
dcb.fDtrControl = FALSE; |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
552 |
if (__inFlowCtrl == FLOW_XONOFF) dcb.fInX = TRUE; /* XOn/XOff handshaking */ |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
553 |
if (__inFlowCtrl == FLOW_HARDWARE) dcb.fDtrControl = TRUE; /* hardware handshaking */ |
1593 | 554 |
} |
555 |
if (__setOutFlowCtrl) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
556 |
dcb.fOutX = FALSE; |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
557 |
dcb.fOutxCtsFlow = FALSE; |
1593 | 558 |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
559 |
if (__outFlowCtrl == FLOW_XONOFF) dcb.fOutX = TRUE; /* XOn/XOff handshaking */ |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
560 |
if (__outFlowCtrl == FLOW_HARDWARE) dcb.fOutxCtsFlow = TRUE; /* hardware handshaking */ |
1593 | 561 |
} |
562 |
||
563 |
if (! SetCommState(port, &dcb)) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
564 |
console_fprintf(stderr, "Win32OS [info]: serial port comm-setup failed\n"); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
565 |
errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) ); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
566 |
goto errExit; |
1593 | 567 |
} |
568 |
# endif /* WIN32 */ |
|
569 |
||
570 |
/* |
|
571 |
* make it a FILE * |
|
572 |
*/ |
|
573 |
# ifdef WIN32 |
|
574 |
{ |
|
2423
f23438963384
First arg in _open_osfhandle is long
Stefan Vogel <sv@exept.de>
parents:
2419
diff
changeset
|
575 |
int _fd = _open_osfhandle((long)port, 0); |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
576 |
fp = fdopen(_fd, "r+"); |
1593 | 577 |
} |
578 |
# else |
|
579 |
fp = fdopen(port, "r+"); |
|
580 |
# endif |
|
581 |
if (! fp) { |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
582 |
console_fprintf(stderr, "Win32OS [info]: fdopen failed\n"); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
583 |
errorNumber = __MKSMALLINT(errno); |
1596 | 584 |
errExit: ; |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
585 |
CloseHandle(port); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
586 |
goto getOutOfhere; |
1593 | 587 |
} |
588 |
||
589 |
{ |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
590 |
OBJ t; |
1593 | 591 |
|
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
592 |
t = __MKEXTERNALADDRESS(fp); |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
593 |
__INST(handle) = t; |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
594 |
__STORE(self, t); |
1593 | 595 |
} |
596 |
||
1596 | 597 |
getOutOfhere: ; |
1599 | 598 |
# undef FLOW_XONOFF |
599 |
# undef FLOW_HARDWARE |
|
600 |
# undef FLOW_NONE |
|
601 |
# undef STOP_1 |
|
602 |
# undef STOP_2 |
|
603 |
# undef STOP_1_5 |
|
604 |
# undef PARITY_ODD |
|
605 |
# undef PARITY_EVEN |
|
606 |
# undef PARITY_NONE |
|
1593 | 607 |
|
608 |
%}. |
|
609 |
"all ok?" |
|
2321
6f4cc7b644db
filePointer -> handle migration
Claus Gittinger <cg@exept.de>
parents:
2020
diff
changeset
|
610 |
handle notNil ifTrue:[ |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
611 |
Lobby register:self. |
1593 | 612 |
] ifFalse:[ |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
613 |
errorNumber isNil ifTrue:[ |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
614 |
self error:'invalid argument(s)'. |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
615 |
] ifFalse:[ |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
616 |
((OperatingSystem errorHolderForNumber:errorNumber) parameter:portName) reportError |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
617 |
]. |
1593 | 618 |
]. |
1846 | 619 |
|
620 |
"Modified: / 12-02-2007 / 12:29:57 / cg" |
|
1593 | 621 |
! ! |
622 |
||
1595 | 623 |
!SerialPort methodsFor:'printing & storing'! |
624 |
||
625 |
printOn:aStream |
|
1903
d62268dffe6b
changed #printOn: print port name (COMx)
Stefan Vogel <sv@exept.de>
parents:
1846
diff
changeset
|
626 |
aStream nextPutAll:'SerialPort('. |
d62268dffe6b
changed #printOn: print port name (COMx)
Stefan Vogel <sv@exept.de>
parents:
1846
diff
changeset
|
627 |
portName printOn:aStream. |
d62268dffe6b
changed #printOn: print port name (COMx)
Stefan Vogel <sv@exept.de>
parents:
1846
diff
changeset
|
628 |
aStream nextPut:$/. |
1595 | 629 |
baudRate printOn:aStream. |
1903
d62268dffe6b
changed #printOn: print port name (COMx)
Stefan Vogel <sv@exept.de>
parents:
1846
diff
changeset
|
630 |
aStream nextPut:$). |
1595 | 631 |
! ! |
632 |
||
633 |
!SerialPort methodsFor:'queries'! |
|
634 |
||
635 |
getName |
|
636 |
"return the name; here, we return the devices name" |
|
637 |
||
638 |
^ portName |
|
639 |
! ! |
|
640 |
||
1593 | 641 |
!SerialPort class methodsFor:'documentation'! |
642 |
||
643 |
version |
|
2423
f23438963384
First arg in _open_osfhandle is long
Stefan Vogel <sv@exept.de>
parents:
2419
diff
changeset
|
644 |
^ '$Header: /cvs/stx/stx/libbasic2/SerialPort.st,v 1.13 2010-02-04 11:48:58 stefan Exp $' |
2419
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
645 |
! |
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
646 |
|
8ea9b41e7b4b
Use __MKEXTERNALADDRESS() instead of __MKOBJ()
Stefan Vogel <sv@exept.de>
parents:
2321
diff
changeset
|
647 |
version_CVS |
2423
f23438963384
First arg in _open_osfhandle is long
Stefan Vogel <sv@exept.de>
parents:
2419
diff
changeset
|
648 |
^ '$Header: /cvs/stx/stx/libbasic2/SerialPort.st,v 1.13 2010-02-04 11:48:58 stefan Exp $' |
1593 | 649 |
! ! |