Devuan fork of gpsd
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

108 lines
4.8 KiB

  1. <sect1 id="gpsdclient.c"><title><filename>libgps_core.c</filename></title>
  2. <informaltable frame='all' pgwide='1'>
  3. <tgroup cols='2'>
  4. <colspec colname='c1'></colspec>
  5. <colspec colname='c2'></colspec>
  6. <spanspec spanname='s1' namest='c1' nameend='c2'></spanspec>
  7. <thead>
  8. <row>
  9. <entry>Functions:-</entry><entry>The client interface library for the <application>gpsd</application> daemon.</entry>
  10. </row>
  11. </thead>
  12. <tfoot>
  13. <row>
  14. <entry spanname='s1' align='left'>Notes based on code of Mon Apr 5 21:38:06 2010 -0400</entry>
  15. </row>
  16. </tfoot>
  17. <tbody>
  18. <row>
  19. <entry><function>struct gps_data_t *gps_open(const char *host, const char *port)</function></entry>
  20. <entry><para>Open a connection to a gps daemon.</para><para>Try to
  21. get a <function>gps_data_t</function> structure. If it fails, return
  22. a NULL.</para><para>Test for a specified host and/or port number,
  23. using defaults if nothing is specified in the command line
  24. invocation.</para><para>Try to connect to the now defined socket; on
  25. error, release the resources and return NULL. On success, initialise
  26. an internal <structname>struct gps_data_t</structname> and return
  27. the pointer to it.</para></entry>
  28. </row>
  29. <row>
  30. <entry><function>struct gps_data_t *gps_open_r(const char *host, const char *port, struct gps_data_t *gpsdata)</function></entry>
  31. <entry><para>Variant of <function>gps_open()</function> for when
  32. re-entrancy is required. Initializes storage passed by the
  33. caller.</para></entry>
  34. </row>
  35. <row>
  36. <entry><function>int gps_close(struct gps_data_t *gpsdata)</function></entry>
  37. <entry><para>Close the fd associated with the
  38. <function>gps_data_t</function> structure and stash the
  39. result.</para><para>If there is a device id stored, NULL it and the
  40. associated path.</para><para>If the device list has any data in it,
  41. free this and mark the number of available devices as
  42. invalid.</para><para>Free the <function>gps_data_t</function>
  43. structure itself and return the stashed <function>close()</function>
  44. result.</para></entry>
  45. </row>
  46. <row>
  47. <entry><function>static void gps_unpack(char *buf, struct gps_data_t *gpsdata)</function></entry>
  48. <entry><para>Keep looping through the data in
  49. <function>buf</function> for JSON objects. Each time one is found,
  50. analyze it and unpack it into the struct pointed at by gpsdata,
  51. setting the gpsdata->set mask appropriately to indicate which data
  52. is valid</para><para>This function is intended for GPSD internal use
  53. only and should not be considered a stable part oof the
  54. API.</para></entry>
  55. </row>
  56. <row>
  57. <entry><function>int gps_poll(struct gps_data_t *gpsdata)</function></entry>
  58. <entry><para>Poll the daemon and if there is no data or an error,
  59. return -1.</para><para>If there is something to read, clear the
  60. buffer, note the time as the received data time and the online time,
  61. then unpack the data.</para><para>If profiling is active, use the
  62. received data time, the fix time and the present time to calculate
  63. the decode time and the client receipt time.</para></entry>
  64. </row>
  65. <row>
  66. <entry><function>int gps_send(struct gps_data_t *gpsdata, const char *fmt, ... )</function></entry>
  67. <entry><para>Gather up the instructions to a
  68. <application>gpsd</application> instance for information to return
  69. and write them to the device.</para><para>If the write fails, return
  70. -1. This entry point is deprecated in favor of
  71. <function>gps_stream()</function></para></entry>
  72. </row>
  73. <row>
  74. <entry><function>bool gps_waiting(struct gps_data_t *gpsdata)</function></entry>
  75. <entry><para>Return a boolean indicating whether input data is waiting on
  76. the daemon socket. Does not block.</para></entry>
  77. </row>
  78. <row>
  79. <entry><function>int gps_stream(struct gps_data_t *gpsdata, unsigned int, void *d)</function></entry>
  80. <entry><para>Set watch and policy flags. This evaluates the flag mask passed
  81. as the second argument, composes a corresponding command in the GPSD
  82. write protocol, and ships it to the daemon. </para></entry>
  83. </row>
  84. <row>
  85. <entry></entry>
  86. <entry><para>The following three functions are guarded by an <function>#ifdef</function> so they only compile if it is required to be able to test the library and set up a command line exerciser interface.</para></entry>
  87. </row>
  88. <row>
  89. <entry><function>static void data_dump(struct gps_data_t *collect, time_t now)</function></entry>
  90. <entry><para>A data dumper used when debugging. It outputs data according to the command line input data.</para></entry>
  91. </row>
  92. <row>
  93. <entry><function>static void dumpline(struct gps_data_t *ud UNUSED, char *buf, size_t ulen UNUSED, int level UNUSED)</function></entry>
  94. <entry><para>A simple call to UNIX <function>puts()</function>.</para></entry>
  95. </row>
  96. <row>
  97. <entry><function>int main(int argc, char *argv[])</function></entry>
  98. <entry><para>A simple command line parser and endless loop to exercise the daemon when debugging.</para></entry>
  99. </row>
  100. </tbody>
  101. </tgroup>
  102. </informaltable>
  103. </sect1>