+ if (trigger_at != -1) {
+ /* a trigger was set up, so we need to tell the frontend
+ * about it.
+ */
+ if (trigger_at > 0) {
+ /* there are pre-trigger samples, send those first */
+ packet.type = DF_LOGIC;
+ packet.length = trigger_at * 4;
+ packet.unitsize = 4;
+ packet.payload = raw_sample_buf;
+ session_bus(user_data, &packet);
+ }
+
+ packet.type = DF_TRIGGER;
+ packet.length = 0;
+ session_bus(user_data, &packet);
+
+ packet.type = DF_LOGIC;
+ packet.length = (limit_samples * 4) - (trigger_at * 4);
+ packet.unitsize = 4;
+ packet.payload = raw_sample_buf + trigger_at * 4;
+ session_bus(user_data, &packet);
+ } else {
+ packet.type = DF_LOGIC;
+ packet.length = limit_samples * 4;
+ packet.unitsize = 4;
+ packet.payload = raw_sample_buf;
+ session_bus(user_data, &packet);
+ }
+ free(raw_sample_buf);
+
+ serial_flush(fd);