Tcm2.5/2.6 code example, Wake c program – PNI TCM 2.6 User Manual

Page 44

Advertising
background image

PNI Sensor Corporation

DOC#1009269 r11

TCM2.5 & TCM2.6 User Manual

Page 44 of 49

TCM2.5/2.6 Code Example

Wake C program

/* wake.c - Sample program to wake the TCM2.5/2.6 after is has been put
in sleep mode */

/* Wake toggles the RTS line to give the TCM2.5/2.6 a (falling) edge */

/* P Milford 1/10/96 */

/* Usage: wake 1 - wakes a tcm2.5/2.6 on com port 1 (default) */

/* wake 2 - wakes a tcm2.5/2.6 on com port 2, etc. */

#include <stdio.h>

#include <stdlib.h> /* for atoi */

#include <conio.h> /* For inp/out */

/* Addresses in IO space of the serial port base addresses */

#define PORT1 0x3F8

#define PORT2 0x2F8

#define PORT3 0x3E8

#define PORT4 0x2E8

#define MCR 4

/* Offset to the Modem control register */

#define RTS 2

/* RTS is bit 2 of the MCR*/

int

main(

int

argc,

char

*argv[])

{

int

tmp, port=PORT1;

/* Defaul to serial port 1 */

/* If there are args, look at the first one only */


if

(argc ==

2

) {

/* Figure out which serial port to use */

switch

(atoi(argv[

1

])) {

case

1

: port = PORT1;

break

;

case

2

: port = PORT2;

break

;

case

3

: port = PORT3;

break

;

case

4

: port = PORT4;

break

;

others: port = PORT1;

};

};

tmp = inp(port+MCR);

/* Read current line status */

outp(port+MCR, tmp ^ RTS);

/* Toggle the RTS line */

outp(port+MCR, tmp);

/* Restore the RTS line */

return

0

;

};


Advertising
This manual is related to the following products: