41 #include <visp3/core/vpConfig.h>
43 #if defined(VISP_HAVE_MODULE_IO) && defined(VISP_HAVE_PARPORT)
46 #include <sys/ioctl.h>
49 #include <sys/types.h>
52 #include <visp3/core/vpDebug.h>
53 #include <visp3/core/vpTime.h>
54 #include <visp3/robot/vpRingLight.h>
71 vpRingLight::vpRingLight() : parport() { off(); }
81 vpRingLight::~vpRingLight() { off(); }
90 void vpRingLight::pulse()
100 int mask_mode_pulse_d2 = 0x00;
101 int mask_pulse_d1 = 0x02;
102 unsigned char data = 0x00;
106 data = data | mask_pulse_d1 | mask_mode_pulse_d2;
108 parport.sendData(data);
111 struct timeval ti, tc;
112 struct timeval tempo;
114 gettimeofday(&ti, 0L);
116 gettimeofday(&tc, 0L);
117 }
while (tc.tv_usec < ti.tv_usec + tempo.tv_usec);
119 data = data & (~mask_pulse_d1);
121 parport.sendData(data);
133 void vpRingLight::pulse(
double time)
143 int mask_mode_pulse_d3 = 0x08;
144 int mask_pulse_d1 = 0x02;
145 unsigned char data = 0x00;
149 data = data | mask_pulse_d1 | mask_mode_pulse_d3;
151 parport.sendData(data);
154 struct timeval ti, tc;
155 gettimeofday(&ti, 0);
157 gettimeofday(&tc, 0);
158 }
while (tc.tv_usec < ti.tv_usec + time * 1000);
160 data = data & (~mask_pulse_d1);
162 parport.sendData(data);
171 void vpRingLight::on()
181 int mask_mode_onoff_d2 = 0x04;
182 int mask_on_d1 = 0x02;
183 unsigned char data = 0x00;
186 data = data | mask_on_d1 | mask_mode_onoff_d2;
188 parport.sendData(data);
197 void vpRingLight::off()
207 int mask_mode_onoff_d2 = 0x04;
208 int mask_off_d1 = 0x00;
209 unsigned char data = 0x00;
212 data = data | mask_off_d1 | mask_mode_onoff_d2;
214 parport.sendData(data);
217 #elif !defined(VISP_BUILD_SHARED_LIBS)
219 void dummy_vpRingLight() { };