Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 3:7d5a6c251111, committed 2021-05-07
- Comitter:
- 19010100419
- Date:
- Fri May 07 12:00:26 2021 +0000
- Parent:
- 2:c9378e6122a7
- Commit message:
- nucleo uart
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Oct 08 15:48:41 2016 +0000
+++ b/main.cpp Fri May 07 12:00:26 2021 +0000
@@ -5,9 +5,8 @@
// Hyperterminal configuration
// 9600 bauds, 8-bit data, no parity
//------------------------------------
-
Serial pc(SERIAL_TX, SERIAL_RX);
-Serial gps(PA_2, PA_3);
+DigitalOut myled(LED1);
/*
* Author: Edoardo De Marchi
* Date: 22-08-14
@@ -15,89 +14,24 @@
*/
-char cDataBuffer[500];
-int i = 0;
-
-
-void Init();
-void parse(char *cmd, int n);
-
-void Init()
-{
- gps.baud(9600);
- pc.baud(9600);
-
- pc.printf("Init OK\n");
-}
-
-
int main()
{
- Init();
- char c;
-
- while(true)
+ pc.printf("Press 'u' to turn LED on,'d' for off\n");
+ while(1)
{
- if(gps.readable())
- {
- if(gps.getc() == '$'); // wait a $
- {
- for(int i=0; i<sizeof(cDataBuffer); i++)
- {
- c = gps.getc();
- if( c == '\r' )
- {
- //pc.printf("%s\n", cDataBuffer);
- parse(cDataBuffer, i);
- i = sizeof(cDataBuffer);
- }
- else
- {
- cDataBuffer[i] = c;
- }
- }
+ char c = pc.getc();
+ wait (0.001);
+ if(c == 'u')
+ {
+ myled = 1;
}
- }
- }
+ if(c == 'd')
+ {
+ myled = 0;
+ }
}
-
-void parse(char *cmd, int n)
-{
-
- char ns, ew, tf, status;
- int fq, nst, fix, date; // fix quality, Number of satellites being tracked, 3D fix
- float latitude, longitude, timefix, speed, altitude;
-
-
- // Global Positioning System Fix Data
- if(strncmp(cmd,"$GPGGA", 6) == 0)
- {
- sscanf(cmd, "$GPGGA,%f,%f,%c,%f,%c,%d,%d,%*f,%f", &timefix, &latitude, &ns, &longitude, &ew, &fq, &nst, &altitude);
- pc.printf("GPGGA Fix taken at: %f, Latitude: %f %c, Longitude: %f %c, Fix quality: %d, Number of sat: %d, Altitude: %f M\n", timefix, latitude, ns, longitude, ew, fq, nst, altitude);
- }
-
- // Satellite status
- if(strncmp(cmd,"$GPGSA", 6) == 0)
- {
- sscanf(cmd, "$GPGSA,%c,%d,%d", &tf, &fix, &nst);
- pc.printf("GPGSA Type fix: %c, 3D fix: %d, number of sat: %d\r\n", tf, fix, nst);
- }
-
- // Geographic position, Latitude and Longitude
- if(strncmp(cmd,"$GPGLL", 6) == 0)
- {
- sscanf(cmd, "$GPGLL,%f,%c,%f,%c,%f", &latitude, &ns, &longitude, &ew, &timefix);
- pc.printf("GPGLL Latitude: %f %c, Longitude: %f %c, Fix taken at: %f\n", latitude, ns, longitude, ew, timefix);
- }
-
- // Geographic position, Latitude and Longitude
- if(strncmp(cmd,"$GPRMC", 6) == 0)
- {
- sscanf(cmd, "$GPRMC,%f,%c,%f,%c,%f,%c,%f,,%d", &timefix, &status, &latitude, &ns, &longitude, &ew, &speed, &date);
- pc.printf("GPRMC Fix taken at: %f, Status: %c, Latitude: %f %c, Longitude: %f %c, Speed: %f, Date: %d\n", timefix, status, latitude, ns, longitude, ew, speed, date);
- }
}
--- a/mbed.bld Sat Oct 08 15:48:41 2016 +0000 +++ b/mbed.bld Fri May 07 12:00:26 2021 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/ed8466a608b4 \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file