org.openuat.sensors
Class ParallelPortPWMReader
java.lang.Object
org.openuat.sensors.AsciiLineReaderBase
org.openuat.sensors.ParallelPortPWMReader
public class ParallelPortPWMReader
- extends AsciiLineReaderBase
This class implements a reader for the data format generated by the small
Linux native code (a C command line program) to sample pulse-width modulated
sensors (e.g. accelerometers) using a standard parallel port.
Because the output format reports a new value whenever a change on the
parallel port occurs, this class implements sampling with a defined sample
rate to generate equidistant sample points.
- Version:
- 1.0
- Author:
- Rene Mayrhofer
Constructor Summary |
ParallelPortPWMReader(java.io.InputStream stream,
int samplerate)
Initializes the parallel port PWM log reader. |
ParallelPortPWMReader(java.lang.String filename,
int samplerate)
Initializes the parallel port PWM log reader. |
Method Summary |
static void |
main(java.lang.String[] args)
|
protected void |
parseLine(java.lang.String line)
A helper function to parse single line of the format produced by
parport-pulsewidth. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ParallelPortPWMReader
public ParallelPortPWMReader(java.lang.String filename,
int samplerate)
throws java.io.FileNotFoundException
- Initializes the parallel port PWM log reader. It only saves the
passed parameters and opens the InputStream to read from the specified
file, and thus implicitly to check if the file exists and can be opened.
- Parameters:
filename
- The log to read from. This may either be a normal log file
when simulation is intended or it can be a FIFO/pipe to read
online data.samplerate
- The sample rate in Hz.
- Throws:
java.io.FileNotFoundException
- When filename does not exist or can not be opened.
ParallelPortPWMReader
public ParallelPortPWMReader(java.io.InputStream stream,
int samplerate)
- Initializes the parallel port PWM log reader. It only saves the
passed parameters. This is an alternative to @see #ParallelPortPWMReader(String, int)
and should only be used in special cases.
- Parameters:
stream
- Specifies the InputStream to read from.samplerate
- The sample rate in Hz.
parseLine
protected void parseLine(java.lang.String line)
- A helper function to parse single line of the format produced by
parport-pulsewidth. This method creates the samples and emits events.
- Specified by:
parseLine
in class AsciiLineReaderBase
- Parameters:
line
- The line to parse.
main
public static void main(java.lang.String[] args)
throws java.io.IOException
- Throws:
java.io.IOException
2005-2006, Rene Mayrhofer.