]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - support/sdk/c/sfsource.h
Merge devel code into the trunk.
[tinyos-2.x.git] / support / sdk / c / sfsource.h
diff --git a/support/sdk/c/sfsource.h b/support/sdk/c/sfsource.h
new file mode 100644 (file)
index 0000000..98f7302
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef SFSOURCE_H
+#define SFSOURCE_H
+
+int open_sf_source(const char *host, int port);
+/* Returns: file descriptor for TinyOS 2.0 serial forwarder at host:port, or
+     -1 for failure
+ */
+
+int init_sf_source(int fd);
+/* Effects: Checks that fd is following the TinyOS 2.0 serial forwarder 
+     protocol. Use this if you obtain your file descriptor from some other
+     source than open_sf_source (e.g., you're a server)
+   Returns: 0 if it is, -1 otherwise
+ */
+
+void *read_sf_packet(int fd, int *len);
+/* Effects: reads packet from serial forwarder on file descriptor fd
+   Returns: the packet read (in newly allocated memory), and *len is
+     set to the packet length
+*/
+
+int write_sf_packet(int fd, const void *packet, int len);
+/* Effects: writes len byte packet to serial forwarder on file descriptor
+     fd
+   Returns: 0 if packet successfully written, -1 otherwise
+*/
+
+#endif