- if(cur_buflen == 0) {
- empty_transfer_count++;
- if(empty_transfer_count > MAX_EMPTY_TRANSFERS) {
- /* the FX2 gave up... end the acquisition, the frontend will work
- * out that the samplecount is short
- */
- packet.type = DF_END;
- session_bus(user_data, &packet);
- num_samples = -1;
- }
- return;
- }
- else
- empty_transfer_count = 0;
-
- trigger_offset = 0;
- if(trigger_stage >= 0)
- {
- for(i = 0; i < cur_buflen; i++)
- {
- if((cur_buf[i] & trigger_mask[trigger_stage]) == trigger_value[trigger_stage])
- {
- /* match on this trigger stage */
- trigger_buffer[trigger_stage] = cur_buf[i];
- trigger_stage++;
- if(trigger_stage == NUM_TRIGGER_STAGES || trigger_mask[trigger_stage] == 0)
- {
- /* match on all trigger stages, we're done */
- trigger_offset = i+1;
-
- /* TODO: send pre-trigger buffer to session bus */
-
- /* tell the frontend we hit the trigger here */
- packet.type = DF_TRIGGER;
- packet.length = 0;
- session_bus(user_data, &packet);
-
- /* send the samples that triggered it, since we're skipping past them */
- packet.type = DF_LOGIC8;
- packet.length = trigger_stage;
- packet.payload = trigger_buffer;
- session_bus(user_data, &packet);
- break;
-
- trigger_stage = TRIGGER_FIRED;
- }
- }
- else if(trigger_stage > 0)
- {
- /* we had a match before, but not in the next sample. however, we may
- * have a match on this stage in the next bit -- trigger on 0001 will
- * fail on seeing 00001, so we need to go back to stage 0 -- but at
- * the next sample from the one that matched originally, which the
- * counter increment at the end of the loop takes care of.
- */
- i -= trigger_stage;
- if(i < -1)
- /* oops, went back past this buffer */
- i = -1;
- /* reset trigger stage */
- trigger_stage = 0;
- }
- }
+ if (cur_buflen == 0) {
+ empty_transfer_count++;
+ if (empty_transfer_count > MAX_EMPTY_TRANSFERS) {
+ /*
+ * The FX2 gave up. End the acquisition, the frontend
+ * will work out that the samplecount is short.
+ */
+ hw_stop_acquisition(-1, user_data);