~ubuntu-branches/ubuntu/intrepid/comedilib/intrepid

« back to all changes in this revision

Viewing changes to testing/cmd_1.c

  • Committer: Bazaar Package Importer
  • Author(s): David Schleef
  • Date: 2004-11-04 11:43:51 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041104114351-a50kaei5yamka8r6
Tags: 0.7.22-2
It helps if the shared library is actually in the package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
161
161
        int total=0;
162
162
        int ret;
163
163
        unsigned int flags = comedi_get_subdevice_flags(device,subdevice);
164
 
 
 
164
        static const int num_samples = 100000;
 
165
        int num_bytes;
 
166
        
 
167
        if((flags & SDF_LSAMPL))
 
168
        {
 
169
                num_bytes = num_samples * sizeof(lsampl_t);
 
170
        }else
 
171
        {
 
172
                num_bytes = num_samples * sizeof(sampl_t);
 
173
        }
165
174
        if(!(flags&SDF_CMD) || !(flags&SDF_WRITEABLE)){
166
175
                printf("not applicable\n");
167
176
                return 0;
175
184
        if(realtime)cmd.flags |= TRIG_RT;
176
185
        cmd.chanlist = chanlist;
177
186
        cmd.scan_end_arg = 1;
178
 
        cmd.stop_arg = 1000000;
 
187
        cmd.stop_arg = num_samples;
179
188
        cmd.chanlist_len = 1;
180
189
        chanlist[0] = CR_PACK(0,0,0);
181
190
 
202
211
                if(verbose)printf("write %d %d\n",ret,total);
203
212
        }
204
213
        
205
 
        {
206
 
                comedi_insn insn;
207
 
                memset(&insn, 0, sizeof(comedi_insn));
208
 
                insn.insn = INSN_INTTRIG;
209
 
                insn.subdev = subdevice;
210
 
                ret = comedi_do_insn(device, &insn);
211
 
                if(ret<0){
212
 
                        perror("comedi_inttrig");
213
 
                        return 0;
214
 
                }
215
 
                if(verbose)printf("inttrig\n");
 
214
        ret = comedi_internal_trigger(device, subdevice, 0);
 
215
        if(ret<0){
 
216
                perror("E: comedi_inttrig");
 
217
                comedi_cancel(device, subdevice);
 
218
                return 0;
216
219
        }
 
220
        if(verbose)printf("inttrig\n");
217
221
 
218
222
        go=1;
219
223
        while(go){
230
234
                }else{
231
235
                        total += ret;
232
236
                        if(verbose)printf("write %d %d\n",ret,total);
 
237
                        //deal with case where output doesn't support stop_src=TRIG_COUNT
 
238
                        if(total >= num_bytes)
 
239
                        {
 
240
                                go = 0;
 
241
                        }
233
242
                }
234
243
        }
235
 
 
 
244
        // make sure all samples have been written out
 
245
        while(1)
 
246
        {       
 
247
                ret = comedi_get_buffer_contents(device, subdevice);
 
248
                if(ret < 0)
 
249
                {
 
250
                        printf("E: comedi_get_buffer_contents() returned %i\n", ret);
 
251
                }else if(ret == 0) break;
 
252
                usleep(10000);
 
253
        }
 
254
        // cancel needed in the case of stop_src==TRIG_NONE
 
255
        if(comedi_cancel(device, subdevice))
 
256
                printf("E: comedi_cancel() failed");
236
257
        return 0;
237
258
}
238
259