Editing Instrument control package
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
Instrument-Control is a package for interfacing the outside world of hardware via Serial, i2c or Parallel interfaces. It is currently under development by Andrius Sutas | Instrument-Control is a package for interfacing the outside world of hardware via Serial, i2c or Parallel interfaces. It is currently under development by Andrius Sutas, you can browse the SVN [http://svn.code.sf.net/p/octave/code/trunk/octave-forge/main/instrument-control/ repository here] and download the package [http://octave.sourceforge.net/instrument-control/index.html here]. | ||
= Examples = | = Examples = | ||
Line 143: | Line 21: | ||
Here is a simple example to get started with the serial package. It tests the RxD and TxD lines. Make sure you have defined a loopback or connected the pins of your adapter. | Here is a simple example to get started with the serial package. It tests the RxD and TxD lines. Make sure you have defined a loopback or connected the pins of your adapter. | ||
{{Code|Serial port example|<syntaxhighlight lang="octave" style="font-size:13px"> | {{Code|Serial port example|<syntaxhighlight lang="octave" style="font-size:13px"> | ||
# Open default serial port ttyUSB0 in default configuration of 115200, 8-N-1 | |||
s0 = serial() | |||
# Opens serial port ttyUSB1 with baudrate of 115200 (config defaults to 8-N-1) | # Opens serial port ttyUSB1 with baudrate of 115200 (config defaults to 8-N-1) | ||
s1 = serial("/dev/ttyUSB1", 115200) | s1 = serial("/dev/ttyUSB1", 115200) | ||
Line 156: | Line 36: | ||
}} | }} | ||
Chaging some configurations is simple done by calling helper functions | |||
{{Code|Serial port example: helper functions|<syntaxhighlight lang="octave" style="font-size:13px"> | {{Code|Serial port example: helper functions|<syntaxhighlight lang="octave" style="font-size:13px"> | ||
srl_baudrate(s1, 9600) # Change baudrate | |||
srl_bytesize(s1, 5) # Change byte size (config becomes 5-N-1) | |||
srl_parity(s1, "E") # Changes parity checking (config becomes 5-E-1), | |||
# possible values [E]ven, [O]dd, [N]one. | |||
srl_stopbits(s1, 2) # Changes stop bits (config becomes 5-E-2), possible | |||
# values 1, 2. | |||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | }} | ||
Most properties can be set at opening time | |||
{{Code|Serial port example: constructor call|<syntaxhighlight lang="octave" style="font-size:13px"> | {{Code|Serial port example: constructor call|<syntaxhighlight lang="octave" style="font-size:13px"> | ||
s2 = serial("/dev/ttyS0", 9600, | s2 = serial("/dev/ttyS0", 9600, 6, "odd", 2) # Opens serial port ttyS0 in | ||
# 9600, 6-O-2 configuration | |||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | }} | ||
Line 180: | Line 55: | ||
Do not forget to close the ports when you are done! | Do not forget to close the ports when you are done! | ||
{{Code||<syntaxhighlight lang="octave" style="font-size:13px"> | {{Code||<syntaxhighlight lang="octave" style="font-size:13px"> | ||
srl_close(s0) # Closes and releases file descriptor | |||
srl_close(s1) # Closes and releases file descriptor | |||
srl_close(s2) # Closes and releases file descriptor | |||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | }} | ||
Line 367: | Line 235: | ||
== i2c == | == i2c == | ||
i2c | |||
[[Category: | [[Category:OctaveForge]] | ||
[[Category:Packages]] |