I've written an application to read data from the serial port that is incoming from a Garmin GPS 16. It functions perfectly. I cannot get PHP to parse the output. I've seen that there are numerous ways of going about it. I've tried just about every one to no avail.
I have attached the application to the thread, if anyone trusts a guy enough to give it a shot... i'd be greatly appreciative.
If you don't pass an argument it outputs the proper syntax... none of which PHP will parse.
Source of gps.exe:
#include <stdio.h>
#include <ctype.h>
#include "ibmcom3.h"
void set_up(int port)
{
int err;
err = com_install(port);
if(err != 0)
{
printf("%d",err);
exit(1);
}
com_raise_dtr();
com_set_speed(4800);
com_set_parity(COM_NONE, STOP_BIT_1);
}
void end()
{
com_lower_dtr();
com_deinstall();
}
int main(int argc,char *argv[])
{
char c, s[100];
int i,run=1;
if(argc == 1)
{
printf("\nGPGGA Message Reader | Written by Tyler Kellen\n\nSyntax: gps [port]\n",argv[0]);
return 1;
}
set_up(atoi(argv[1]));
while(run)
{
c = com_rx();
if(c == '$')
{
i=0;
s[i] = c;
while(c != 0x0d)
{
c = com_rx();
if((c != '\0') && (isalnum(c) || isspace(c) || ispunct(c)))
{
i++;
s[i] = c;
}
s[i+1] = '\0';
}
if(s[3] == 'G' && s[4] == 'G' && s[5] == 'A')
{
printf("%s\n",s);
run=0;
}
}
}
end();
return 0;
}
also, i'm on WinXPPro with Apache and PHP 4.2.2