EasyManuals Logo

STW TC1 User Manual

STW TC1
374 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #85 background imageLoading...
Page #85 background image
6 Software
User Manual 85/374
6.10 Digital Input / Output
High Level Hardware Access
Example: C - Code Read / Write on PIN1
// This example describes how to read / write on /proc/stw_io/PIN1
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <fcntl.h>
#include "stwtypes.h"
void mv_ToggleOutput (void)
{
charn cn_Status = 0;
fd_set t_Readfds;
struct timeval t_Timeout;
sint16 s16_Fd; // File descriptor
// Set timeout to zero --> no wait time
t_Timeout.tv_sec = 0;
t_Timeout.tv_usec = 0;
s16_Fd = open ("/proc/stw_io/PIN1", O_RDWR); // Open PIN1
if (s16_Fd >= 0)
{
// Clear fds
FD_ZERO (&t_Readfds);
// Set
FD_SET (s16_Fd, &t_Readfds);
if (select (s16_Fd + 1, &t_Readfds, NULL, NULL, &t_Timeout) > 0)
{
// Check if the corresponding bit is set in the fds
if (FD_ISSET (s16_Fd, &t_Readfds))
{
// Read from /proc/stw_io/PIN1
(void)read (s16_Fd, &cn_Status, sizeof (charn));
// If cn_Status is not Zero 0 == 0x30 than set cn_Status to zero,
// else set it to 1
cn_Status = (cn_Status != 0x30)? 0x30: 0x31;
// Write to /proc/stw_io/PIN1
(void) write (s16_Fd, &cn_Status, sizeof (charn));
}
}
(void) close(s16_Fd);
}
}
Low Level Hardware Access
Path
Input
information
Output
information
Description
/proc/stw_io/PIN1
p1
p2
This user space interface reads and writes on digital input /
output PIN.
p1:
< 0 > .. sets digital value to low level
< 1..n > .. sets digital value to high level
p2:

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the STW TC1 and is the answer not in the manual?

STW TC1 Specifications

General IconGeneral
BrandSTW
ModelTC1
CategoryController
LanguageEnglish