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 7: | Line 7: | ||
{| class="wikitable" style="text-align:center" | {| class="wikitable" style="text-align:center" | ||
|- | |- | ||
! !! Linux | ! !! Linux !! Windows (Cygwin) !! Windows (native) !! FreeBSD !! Mac OS X | ||
|- | |- | ||
! Serial | ! Serial | ||
| bgcolor="green" | v0.1.0 || bgcolor="green" | v0.2.0 || | | bgcolor="green" | v0.1.0 || bgcolor="green" | v0.2.0 || - || bgcolor="yellow" | WIP || bgcolor="yellow" | WIP | ||
|- | |- | ||
! Parallel | ! Parallel | ||
| bgcolor="green" | v0.1.0 || - | | bgcolor="green" | v0.1.0 || - || - || bgcolor="yellow" | WIP || - | ||
|- | |- | ||
! i2c | ! i2c | ||
| bgcolor="green" | v0.1.0 || - | | bgcolor="green" | v0.1.0 || - || - || bgcolor="yellow" | WIP || - | ||
|- | |- | ||
! TCP | ! TCP | ||
| bgcolor="green" | v0.2.0 || bgcolor="green" | v0.2.0 || bgcolor="green" | v0.2.0 || | | bgcolor="green" | v0.2.0 || bgcolor="green" | v0.2.0 || bgcolor="green" | v0.2.0 || - || - | ||
|- | |- | ||
! USBTMC | ! USBTMC | ||
| bgcolor="green" | v0.2.0 || - | | bgcolor="green" | v0.2.0 || - || - || - || - | ||
|- | |- | ||
! GPIB | ! GPIB | ||
| bgcolor="green" | v0.2.0 | | bgcolor="green" | v0.2.0 || - || - ||- || - | ||
|- | |- | ||
! VXI11 | ! VXI11 | ||
| bgcolor="green" | v0.2.0|| bgcolor="green" | v0.2.0 | | bgcolor="green" | v0.2.0|| bgcolor="green" | v0.2.0 || - || - || - | ||
|} | |} | ||
Where: <span style="background:green">(VER)</span> - Included since VER version; <span style="background:yellow">(WIP)</span> - Work In Progress and will probably be included in next release | Where: <span style="background:green">(VER)</span> - Included since VER version; <span style="background:yellow">(WIP)</span> - Work In Progress and will probably be included in next release; (-) - Not supported / Untested. | ||
You might see errors while doing "pkg install", which mean that package is unable to support related interface on your platform (e.g. due to missing header files), therefore one should <b>always</b> check for the supported interfaces before trying to use them: | You might see errors while doing "pkg install", which mean that package is unable to support related interface on your platform (e.g. due to missing header files), therefore one should <b>always</b> check for the supported interfaces before trying to use them: | ||
Line 46: | Line 37: | ||
{{Code|Check for interface support|<syntaxhighlight lang="octave" style="font-size:13px"> | {{Code|Check for interface support|<syntaxhighlight lang="octave" style="font-size:13px"> | ||
pkg load instrument-control | pkg load instrument-control | ||
if | if (exist("serial") == 3) | ||
disp("Serial: Supported") | disp("Serial: Supported") | ||
else | else | ||
Line 55: | Line 45: | ||
#similarly with: | #similarly with: | ||
# | #exist("parallel") == 3 | ||
# | #exist("i2c") == 3 | ||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
Line 67: | Line 57: | ||
For VXI11 support, please install 'rpcgen', 'libtirpc-devel', and 'libtirpc1' before installing instrument-control. | For VXI11 support, please install 'rpcgen', 'libtirpc-devel', and 'libtirpc1' before installing instrument-control. | ||
= Examples = | = Examples = | ||
Line 143: | Line 78: | ||
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 93: | ||
}} | }} | ||
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> | ||
}} | }} | ||
Line 180: | Line 112: | ||
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 292: | ||
== i2c == | == i2c == | ||
i2c | |||
== TCP == | == TCP == | ||
Line 471: | Line 356: | ||
# Convert uint8 array to string, | # Convert uint8 array to string, | ||
char(data) | char(data) | ||
# close | # close usbtmc session | ||
vxi11_close(t0) | vxi11_close(t0) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | }} | ||
=== Limitations === | === Limitations === | ||
For now, | For now, | ||
Line 503: | Line 387: | ||
* Every read or write command opens and closes a new gpib session, since the linux-gpib session pointer is only valid for single command. | * Every read or write command opens and closes a new gpib session, since the linux-gpib session pointer is only valid for single command. | ||
[[Category:Octave-Forge]] | |||
[[Category:Octave Forge |