#include "config.h"
#include "xgpsspeed.h"
#include "xgpsspeed.icon"
#include "nmea.h"
#include <unistd.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <fcntl.h>
Go to the source code of this file.
Data Structures | |
struct | _XGpsResources |
Defines | |
#define | BUFSIZE 4096 |
#define | DEFAULTPORT "2947" |
#define | Offset(field) (XtOffset(XGpsResources *, field)) |
Typedefs | |
typedef struct _XGpsResources | XGpsResources |
Functions | |
static void | open_input (XtAppContext app) |
int | errexit (char *s) |
int | main (int argc, char **argv) |
Usage () | |
void | update_display () |
static void | handle_input (XtPointer client_data, int *source, XtInputId *id) |
int | my_serial_open () |
Variables | |
char | latd |
char | lond |
double | latitude |
double | longitude |
int | device_type |
int | debug = 0 |
Widget | toplevel |
Widget | base |
Widget | tacho |
Widget | label |
Widget | title |
static XrmOptionDescRec | options [] |
XGpsResources | resources |
static XtResource | my_resources [] |
String | fallback_resources [] |
#define BUFSIZE 4096 |
#define Offset | ( | field | ) | (XtOffset(XGpsResources *, field)) |
typedef struct _XGpsResources XGpsResources |
static void open_input | ( | XtAppContext | app | ) | [static] |
Definition at line 200 of file gps.ex.c.
References handle_input(), and my_serial_open().
Referenced by main().
00201 { 00202 int input = 0; 00203 XtInputId input_id; 00204 00205 input = my_serial_open(); 00206 00207 input_id = XtAppAddInput(app, input, (XtPointer) XtInputReadMask, 00208 handle_input, NULL); 00209 }
int errexit | ( | char * | s | ) |
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 61 of file gps.ex.c.
References base, fallback_resources, label, my_resources, open_input(), options, tacho, and toplevel.
00062 { 00063 Arg args[10]; 00064 XtAppContext app; 00065 Cardinal i; 00066 char *cp; 00067 int ret; 00068 00069 00070 toplevel = 00071 XtVaAppInitialize(&app, "XGpsSpeed", options, XtNumber(options), 00072 &argc, argv, fallback_resources, NULL); 00073 00074 XtGetApplicationResources(toplevel, (caddr_t) & resources, 00075 my_resources, XtNumber(my_resources), 00076 NULL, (Cardinal) 0); 00077 00078 /**** Shell Widget ****/ 00079 i = 0; 00080 XtSetArg(args[0], XtNiconPixmap, 00081 XCreateBitmapFromData(XtDisplay(toplevel), 00082 XtScreen(toplevel)->root, xgps_bits, 00083 xgps_width, xgps_height)); 00084 i++; 00085 XtSetValues(toplevel, args, i); 00086 00087 /**** Form widget ****/ 00088 base = 00089 XtCreateManagedWidget("pane", panedWidgetClass, toplevel, NULL, 0); 00090 00091 /**** Label widget (Title) ****/ 00092 i = 0; 00093 XtSetArg(args[i], XtNlabel, "GPS Speedometer"); 00094 i++; 00095 label = XtCreateManagedWidget("title", labelWidgetClass, base, args, i); 00096 00097 /**** Label widget ****/ 00098 i = 0; 00099 XtSetArg(args[i], XtNlabel, "km/s"); 00100 i++; 00101 label = XtCreateManagedWidget("name", labelWidgetClass, base, args, i); 00102 00103 /**** Tachometer widget ****/ 00104 tacho = XtCreateManagedWidget("metres", 00105 tachometerWidgetClass, base, NULL, 0); 00106 00107 XtRealizeWidget(toplevel); 00108 open_input(app); 00109 00110 XtAppMainLoop(app); 00111 }
Usage | ( | ) |
void update_display | ( | ) |
Definition at line 128 of file gps.ex.c.
References tacho.
Referenced by handle_input().
00129 { 00130 //int new = rint(gNMEAdata.speed * 6076.12 / 5280); 00131 int new = rint(gNMEAdata.speed); 00132 #if 0 00133 fprintf(stderr, "gNMEAspeed %f scaled %f %d\n", gNMEAdata.speed, 00134 rint(gNMEAdata.speed * 5208 / 6706.12), 00135 (int) rint(gNMEAdata.speed * 5208 / 6706.12)); 00136 #endif 00137 if (new > 400) 00138 new = 400; 00139 00140 TachometerSetValue(tacho, new); 00141 }
static void handle_input | ( | XtPointer | client_data, | |
int * | source, | |||
XtInputId * | id | |||
) | [static] |
Definition at line 143 of file gps.ex.c.
References BUFSIZE, and update_display().
Referenced by open_input().
00145 { 00146 double speed; 00147 static UINT8 buf[BUFSIZE]; /* that is more than a sentence */ 00148 static int offset = 0; 00149 int count; 00150 int flags; 00151 00152 ioctl(*source, FIONREAD, &count); 00153 00154 /* Make the port NON-BLOCKING so reads will not wait if no data */ 00155 if ((flags = fcntl(*source, F_GETFL)) < 0) 00156 return; 00157 if (fcntl(*source, F_SETFL, flags | O_NDELAY) < 0) 00158 return; 00159 00160 while (offset < BUFSIZE && count--) { 00161 if (read(*source, buf + offset, 1) != 1) 00162 return; 00163 00164 if (buf[offset] == '\n') { 00165 if (buf[offset - 1] == '\r') 00166 buf[offset - 1] = '\0'; 00167 handle_message(buf); 00168 update_display(); 00169 offset = 0; 00170 return; 00171 } 00172 offset++; 00173 } 00174 }
int my_serial_open | ( | ) |
Definition at line 176 of file gps.ex.c.
References DEFAULTPORT, and errexit().
Referenced by open_input().
00177 { 00178 char *temp; 00179 char *p; 00180 char *port = DEFAULTPORT; 00181 char *device_name = "localhost"; 00182 int one = 1; 00183 int ttyfd; 00184 00185 temp = malloc(strlen(device_name) + 1); 00186 strcpy(temp, device_name); 00187 00188 /* temp now holds the HOSTNAME portion and port the port number. */ 00189 ttyfd = connectTCP(temp, port); 00190 free(temp); 00191 port = 0; 00192 00193 setsockopt(ttyfd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(one)); 00194 00195 if (write(ttyfd, "r\n", 2) != 2) 00196 errexit("Can't write to socket"); 00197 return ttyfd; 00198 }
int device_type |
int debug = 0 |
Definition at line 18 of file gps.ex.c.
Referenced by analyseACK(), analyseBeacon(), analyseCTS(), analyseData(), analyseMGMT(), analyseProbeRep(), analyseProbeReq(), analysePSPOLL(), analyseRTS(), AnalyseTAG221(), ChangeChannel_th(), ChannelToStr(), check_keys_th(), dataIsCrypted(), dump_msg(), extract_radiotap_field(), FillRadioData(), findAvailableIF(), getPacketHOSTAP(), getPacketIPW(), getPacketMADWIFI_NG(), getPacketWLAN(), IDS_Var_SeqNum(), IfconfigSetFlags(), IwconfigSetChannel(), LogDetectedClient(), LogPutIsP2P(), LogPutTimestamp(), LogWriteHisto(), main(), memcpy_buff(), openCardHERMES(), openCardHOSTAP(), openCardMADWIFI_NG(), openCardWLAN(), openPacketAIRJACK(), openPacketCISCO(), parse_keystring(), ParseCommandLine(), processPacket(), ProcessTagBits(), RateToString(), selectChannelAIRJACK(), selectChannelIPW(), selectChannelWLAN(), sendDeauth(), shutCardHERMES(), shutCardWLAN(), UpdateOtherInformation(), and WritePanel().
Widget tacho |
XrmOptionDescRec options[] [static] |
XtResource my_resources[] [static] |
String fallback_resources[] |