25 #include <sys/types.h>
26 #include "libpruio/pruio.h"
27 #include "libpruio/pruio_pins.h"
45 struct timeval timeout;
49 FD_SET(STDIN_FILENO, &set);
53 timeout.tv_usec = mseconds * 1000;
55 return TEMP_FAILURE_RETRY(select(FD_SETSIZE,
61 int main(
int argc,
char **argv)
66 printf(
"initialisation failed (%s)\n", Io->
Errr);
break;}
69 printf(
"failed setting input @P_IN (%s)\n", Io->
Errr);
break;}
77 printf(
"failed setting output @P_OUT (%s)\n", Io->
Errr);
break;}
81 printf(
"config failed (%s)\n", Io->
Errr);
break;}
83 struct termios oldt, newt;
84 tcgetattr( STDIN_FILENO, &oldt );
86 newt.c_lflag &= ~( ICANON );
89 tcsetattr( STDIN_FILENO, TCSANOW, &newt );
94 case '0' :
d0 = 0.0;
break;
95 case '1' :
d0 = 0.1;
break;
96 case '2' :
d0 = 0.2;
break;
97 case '3' :
d0 = 0.3;
break;
98 case '4' :
d0 = 0.4;
break;
99 case '5' :
d0 = 0.5;
break;
100 case '6' :
d0 = 0.6;
break;
101 case '7' :
d0 = 0.7;
break;
102 case '8' :
d0 = 0.8;
break;
103 case '9' :
d0 = 0.9;
break;
104 case ',' :
d0 = 1.0;
break;
105 case '.' :
d0 = 1.0;
break;
106 case 'm' :
f0 = (
f0 > 5.5 ?
f0 - 5. : .5);
break;
107 case 'p' :
f0 = (
f0 < 999995. ?
f0 + 5. : 1000000.);
break;
108 case '*' :
f0 = (
f0 < 500000. ?
f0 * 2 : 1000000.);
break;
109 case '/' :
f0 = (
f0 > 1. ?
f0 / 2 : .5);
break;
110 case '+' :
f0 = 1000000.;
break;
111 case '-' :
f0 = .5;
break;
112 default:
goto finish;
115 printf(
"failed setting PWM output (%s)\n", Io->
Errr);
break;}
117 printf(
"\n--> Frequency: %10f , Duty: %10f\n",
f0,
d0);
121 printf(
"failed reading input @P_IN (%s)\n", Io->
Errr);
break;}
123 printf(
"\r Frequency: %10f , Duty: %10f ",
f1,
d1);
124 fflush(STDIN_FILENO);
128 tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
char * pruio_config(pruIo *Io, uint32 Samp, uint32 Mask, uint32 Tmr, uint16 Mds)
Wrapper function for PruIo::config().
char * pruio_cap_Value(pruIo *Io, uint8 Ball, float_t *Hz, float_t *Du)
Wrapper function for CapMod::Value().
float float_t
float data type.
char * pruio_pwm_setValue(pruIo *Io, uint8 Ball, float_t Hz, float_t Du)
Wrapper function for PwmMod::setValue().
pruIo * pruio_new(uint16 Act, uint8 Av, uint32 OpD, uint8 SaD)
Wrapper function for the constructor PruIo::PruIo().
char * pruio_cap_config(pruIo *Io, uint8 Ball, float_t FLow)
Wrapper function for CapMod::config().
void pruio_destroy(pruIo *Io)
Wrapper function for the destructor PruIo::~PruIo().
@ PRUIO_DEF_ACTIVE
Activate all subsystems.
const ANY_PTR NULL
The NULL pointer.
Float_t d1
Variable for calculated duty cycle.
Float_t d0
The required duty cycle.
Float_t f1
Variable for calculated frequency.
#define P_OUT
The pin for PWM output.
int isleep(unsigned int mseconds)
Wait for keystroke or timeout.
int main(int argc, char **argv)
The main function.
#define P_IN
The pin for CAP input.
Wrapper structure for PruIo.
char * Errr
Pointer for error messages.