Gpio1 Test; Description; Tcl Code - Newport XPS-Q8 Manual

Universal high-performance motion controller/driver
Table of Contents

Advertisement

XPS-Q8
7.3

GPIO1 Test

7.3.1

Description

This example opens a TCP connection. It sets the value to 255 to the mask and the
output GPIO1.DO, then gets this output value and assigns it to the variable OA. The
program sets the value of 255 to the mask and the value of 0 to the output GPIO1.DO,
then gets this output value and assigns it to variable OB. It sets the value of 63 to the
mask and the value of 255 to the output GPIO1.DO, then gets this output value and
assigns it to the variable OC. After the settings, the program tests the value of the
variables OA, OB and OC. Finally, the program ends by closing the socket.
Please see the sections:
4 Principle of a Tcl script redirection to a telnet session.
6 Proposed function for error handling.
7.3.2

Tcl Code

# Set channel's name to be used for telnet.
# In this example we assume it is passed to the script as the
# first argument, if not specified output to stdio.
# Open the channel for read mode and get its id,
# this is the id that will be passed to puts function.
if
{$tcl_argv(0) != 0} {
set
telnetOut [ open "/dev/$tcl_argv(0)" r+]
else
}
{
set
telnetOut stdout
}
# Initialization
set
120
TimeOut
set
output
"GPIO1.DO"
set
input
"GPIO1.DI"
# Open TCP socket
set
code
[catch
if
{$code != 0} {
puts
$telnetOut "OpenConnection failed => $code"
# Force transfer to channel's output buffer
flush
$telnetOut
else
}
{
# Set output of GPIO1 to 255
set
code
[catch
if
{$code != 0} {
DisplayErrorAndClose $socketID $code "GPIODigitalSet" $telnetOut
return
}
# Get value of output of GPIO1 and store it in OA
set
code
[catch
if
{$code != 0} {
DisplayErrorAndClose $socketID $code "GPIODigitalGet" $telnetOut
return
else
}
{
puts
$telnetOut "OA = $OA"
# Force transfer to channel's output buffer
flush
$telnetOut
}
"OpenConnection $TimeOut socketID"]
"GPIODigitalSet $socketID $output
"GPIODigitalGet $socketID $output OA"]
29
Tcl Manual
255
255"]
EDH0307En1041 — 10/17

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents