| ︙ | | | ︙ | |
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
* Removes the serial event source.
*
*----------------------------------------------------------------------
*/
static void
SerialExitHandler(
ClientData dummy) /* Old window proc */
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
SerialInfo *infoPtr;
(void)dummy;
/*
* Clear all eventually pending output. Otherwise Tcl's exit could totally
* block, because it performs a blocking flush on all open channels. Note
* that serial write operations may be blocked due to handshake.
*/
|
|
<
|
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
* Removes the serial event source.
*
*----------------------------------------------------------------------
*/
static void
SerialExitHandler(
TCL_UNUSED(ClientData))
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
SerialInfo *infoPtr;
/*
* Clear all eventually pending output. Otherwise Tcl's exit could totally
* block, because it performs a blocking flush on all open channels. Note
* that serial write operations may be blocked due to handshake.
*/
|
| ︙ | | | ︙ | |
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
* Resets the process list.
*
*----------------------------------------------------------------------
*/
static void
ProcExitHandler(
ClientData dummy) /* Old window proc */
{
(void)dummy;
Tcl_MutexLock(&serialMutex);
initialized = 0;
Tcl_MutexUnlock(&serialMutex);
}
/*
*----------------------------------------------------------------------
|
|
<
<
|
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
* Resets the process list.
*
*----------------------------------------------------------------------
*/
static void
ProcExitHandler(
TCL_UNUSED(ClientData))
{
Tcl_MutexLock(&serialMutex);
initialized = 0;
Tcl_MutexUnlock(&serialMutex);
}
/*
*----------------------------------------------------------------------
|
| ︙ | | | ︙ | |
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
|
#ifdef __cplusplus
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
void
SerialSetupProc(
ClientData dummy, /* Not used. */
int flags) /* Event flags as passed to Tcl_DoOneEvent. */
{
SerialInfo *infoPtr;
int block = 1;
int msec = INT_MAX; /* min. found block time */
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
(void)dummy;
if (!(flags & TCL_FILE_EVENTS)) {
return;
}
/*
* Look to see if any events handlers installed. If they are, do not
|
|
<
|
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
|
#ifdef __cplusplus
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
void
SerialSetupProc(
TCL_UNUSED(ClientData),
int flags) /* Event flags as passed to Tcl_DoOneEvent. */
{
SerialInfo *infoPtr;
int block = 1;
int msec = INT_MAX; /* min. found block time */
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
if (!(flags & TCL_FILE_EVENTS)) {
return;
}
/*
* Look to see if any events handlers installed. If they are, do not
|
| ︙ | | | ︙ | |
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
|
* May queue an event.
*
*----------------------------------------------------------------------
*/
static void
SerialCheckProc(
ClientData dummy, /* Not used. */
int flags) /* Event flags as passed to Tcl_DoOneEvent. */
{
SerialInfo *infoPtr;
SerialEvent *evPtr;
int needEvent;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
COMSTAT cStat;
unsigned int time;
(void)dummy;
if (!(flags & TCL_FILE_EVENTS)) {
return;
}
/*
* Queue events for any ready serials that don't already have events
|
|
<
|
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
|
* May queue an event.
*
*----------------------------------------------------------------------
*/
static void
SerialCheckProc(
TCL_UNUSED(ClientData),
int flags) /* Event flags as passed to Tcl_DoOneEvent. */
{
SerialInfo *infoPtr;
SerialEvent *evPtr;
int needEvent;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
COMSTAT cStat;
unsigned int time;
if (!(flags & TCL_FILE_EVENTS)) {
return;
}
/*
* Queue events for any ready serials that don't already have events
|
| ︙ | | | ︙ | |
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
|
*
*----------------------------------------------------------------------
*/
static int
SerialCloseProc(
ClientData instanceData, /* Pointer to SerialInfo structure. */
Tcl_Interp *dummy, /* For error reporting. */
int flags)
{
SerialInfo *serialPtr = (SerialInfo *) instanceData;
int errorCode = 0, result = 0;
SerialInfo *infoPtr, **nextPtrPtr;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
(void)dummy;
if ((flags & (TCL_CLOSE_READ | TCL_CLOSE_WRITE)) != 0) {
return EINVAL;
}
if (serialPtr->validMask & TCL_READABLE) {
|
|
<
|
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
|
*
*----------------------------------------------------------------------
*/
static int
SerialCloseProc(
ClientData instanceData, /* Pointer to SerialInfo structure. */
TCL_UNUSED(Tcl_Interp *),
int flags)
{
SerialInfo *serialPtr = (SerialInfo *) instanceData;
int errorCode = 0, result = 0;
SerialInfo *infoPtr, **nextPtrPtr;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
if ((flags & (TCL_CLOSE_READ | TCL_CLOSE_WRITE)) != 0) {
return EINVAL;
}
if (serialPtr->validMask & TCL_READABLE) {
|
| ︙ | | | ︙ | |
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
|
*
*----------------------------------------------------------------------
*/
static int
SerialGetHandleProc(
ClientData instanceData, /* The serial state. */
int direction, /* TCL_READABLE or TCL_WRITABLE */
ClientData *handlePtr) /* Where to store the handle. */
{
SerialInfo *infoPtr = (SerialInfo *) instanceData;
(void)direction;
*handlePtr = (ClientData) infoPtr->handle;
return TCL_OK;
}
/*
*----------------------------------------------------------------------
|
|
<
|
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
|
*
*----------------------------------------------------------------------
*/
static int
SerialGetHandleProc(
ClientData instanceData, /* The serial state. */
TCL_UNUSED(int) /*direction*/,
ClientData *handlePtr) /* Where to store the handle. */
{
SerialInfo *infoPtr = (SerialInfo *) instanceData;
*handlePtr = (ClientData) infoPtr->handle;
return TCL_OK;
}
/*
*----------------------------------------------------------------------
|
| ︙ | | | ︙ | |