aboutsummaryrefslogtreecommitdiff
path: root/src/modules/systemlib/hx_stream.h
diff options
context:
space:
mode:
authorAnton Babushkin <anton.babushkin@me.com>2013-08-15 10:33:45 +0200
committerAnton Babushkin <anton.babushkin@me.com>2013-08-15 10:33:45 +0200
commit7476b03543f879df5ea29d44be147ff4926f8216 (patch)
treee1c056fa3e12b2c2c3ae601ae2835ac086b60338 /src/modules/systemlib/hx_stream.h
parent39ae01dd07d53e3509826ae3737fc6a509adec34 (diff)
parentd2f19c7d84030ad6ed1f6c17538fa96864c5dcef (diff)
downloadpx4-firmware-7476b03543f879df5ea29d44be147ff4926f8216.tar.gz
px4-firmware-7476b03543f879df5ea29d44be147ff4926f8216.tar.bz2
px4-firmware-7476b03543f879df5ea29d44be147ff4926f8216.zip
Merge branch 'master' into new_state_machine_drton
Diffstat (limited to 'src/modules/systemlib/hx_stream.h')
-rw-r--r--src/modules/systemlib/hx_stream.h42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/modules/systemlib/hx_stream.h b/src/modules/systemlib/hx_stream.h
index 128689953..1f3927222 100644
--- a/src/modules/systemlib/hx_stream.h
+++ b/src/modules/systemlib/hx_stream.h
@@ -58,7 +58,8 @@ __BEGIN_DECLS
* Allocate a new hx_stream object.
*
* @param fd The file handle over which the protocol will
- * communicate.
+ * communicate, or -1 if the protocol will use
+ * hx_stream_start/hx_stream_send_next.
* @param callback Called when a frame is received.
* @param callback_arg Passed to the callback.
* @return A handle to the stream, or NULL if memory could
@@ -80,6 +81,7 @@ __EXPORT extern void hx_stream_free(hx_stream_t stream);
*
* Any counter may be set to NULL to disable counting that datum.
*
+ * @param stream A handle returned from hx_stream_init.
* @param tx_frames Counter for transmitted frames.
* @param rx_frames Counter for received frames.
* @param rx_errors Counter for short and corrupt received frames.
@@ -90,6 +92,44 @@ __EXPORT extern void hx_stream_set_counters(hx_stream_t stream,
perf_counter_t rx_errors);
/**
+ * Reset a stream.
+ *
+ * Forces the local stream state to idle.
+ *
+ * @param stream A handle returned from hx_stream_init.
+ */
+__EXPORT extern void hx_stream_reset(hx_stream_t stream);
+
+/**
+ * Prepare to send a frame.
+ *
+ * Use this in conjunction with hx_stream_send_next to
+ * set the frame to be transmitted.
+ *
+ * Use hx_stream_send() to write to the stream fd directly.
+ *
+ * @param stream A handle returned from hx_stream_init.
+ * @param data Pointer to the data to send.
+ * @param count The number of bytes to send.
+ * @return Zero on success, -errno on error.
+ */
+__EXPORT extern int hx_stream_start(hx_stream_t stream,
+ const void *data,
+ size_t count);
+
+/**
+ * Get the next byte to send for a stream.
+ *
+ * This requires that the stream be prepared for sending by
+ * calling hx_stream_start first.
+ *
+ * @param stream A handle returned from hx_stream_init.
+ * @return The byte to send, or -1 if there is
+ * nothing left to send.
+ */
+__EXPORT extern int hx_stream_send_next(hx_stream_t stream);
+
+/**
* Send a frame.
*
* This function will block until all frame bytes are sent if