para: Control the parallel port interface from R under Windows

Description Usage Arguments Value Note Author(s) See Also Examples

View source: R/para.R

Description

Switch individual channels on or off in the parallel port interface card, or read its current state.

Usage

1
para(state, change = TRUE, port = getOption("para_port"))

Arguments

state

A logical vector of length 8 indicating the state (on or off) for each of the eight individual channels in the parallel interface card.

change

If TRUE (by default), change the channels, otherwise change nothing but just read the current channels state from the card.

port

The lpt port to which the card is connected. Currently, only standard LPT1, LPT2 or LPT3 ports are recognized (use lpt1, lpt2 or lpt3, respectively, or their equivalent numbers, 1, 2 or 3). The default value is stored in the para_port option, otherwise, it is considered to be "lpt1".

Value

If change = TRUE, the function returns TRUE in case of success, or FALSE otherwise (note that failure to load required dlls, or trying to switch to a nonexistant LPT port raise an error).

If change = FALSE, returns a vector of logical of length 8 indicating the current state of the interface card. If state was provided, its names are reused in the returned logical vector.

Note

These functions use the inpout32.dll and lpttcl.dll version 3.0 that are provided in the /bin subdirectory of this package. These dlls work only under Windows (95 -> XP) and are probably not compatible with Windows Vista or higher. They do not work either under Linux or Mac OS X. You must also copy these dlls in the /windows/system32 directory (administrator rights required) before you can use them.

Author(s)

Philippe Grosjean Philippe.Grosjean@umons.ac.be

See Also

wtw_open(), iks_open()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
# If the parallel interface card is connected to LPT1, this should work:
options(para_port = "lpt1")	# Change this to 2 or 3, if needed
para(c(T, T, T, T, T, T, T, T))    # All channels ON
para(c(T, F, T, F, T, F, T, F))    # All odd channels ON
para(c(F, F, F, F, F, F, F, F))    # All channels OFF

# Use a named vector for better tracking of the different channels
st <- c(ch1 = TRUE, ch2 = FALSE, ch3 = FALSE, ch4 = TRUE,
        ch5 = TRUE, ch6 = FALSE, ch7 = FALSE, ch8 = TRUE)
st
para(c(F, T, F, T, F, T, F, T))    # All even channels ON
para(st, FALSE) # Read current config, keeping channel names from st

## End(Not run)

EcoNum/econum documentation built on May 9, 2020, 3:57 a.m.