Srinivasan Ramasamy / Mbed 2 deprecated EC

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include <stdio.h>
00003 
00004 
00005 DigitalOut myled(LED1);
00006 Serial pc(USBTX, USBRX);
00007 Serial async_port(p9,p10);
00008 
00009 
00010 int main() {
00011     char A[100];
00012     char *pch;
00013     int t=0;
00014     
00015     pc.printf("EC = ");
00016     async_port.baud(38400);
00017     //async_port.puts("27,b\r");
00018     
00019     //async_port.puts("C0\r");
00020     
00021     /*async_port.puts("O,S,1\r");
00022     wait(1);
00023     async_port.puts("O,SG,1\r");
00024     wait(1);
00025     async_port.puts("O,TDS,1\r");
00026     wait(1);
00027     async_port.puts("O,EC,1\r");
00028     wait(1);*/
00029     async_port.puts("R\r");
00030     
00031     //async_port.puts("L,1\r");
00032     
00033     
00034     //async_port.puts("K,1.0\r");
00035     //async_port.puts("Cal,dry\r");
00036     //async_port.puts("Cal,high,80000\r");
00037     //async_port.puts("Cal,low,12800\r");
00038     //async_port.puts("Cal,?\r");
00039     
00040     wait(1);
00041     async_port.gets(A,20);
00042     //pc.printf(A);
00043     pc.printf("\n\r");
00044     pch = strtok (A,",");
00045     
00046   while (pch != NULL)
00047   {
00048     switch(t)
00049     {
00050        case 0: pc.printf ("EC = %s\n",pch); break;
00051        case 1: pc.printf ("TDS = %s\n",pch); break;
00052        case 2: pc.printf ("SAL = %s\n",pch); break;
00053        case 3: pc.printf ("SG = %s\n",pch); break;
00054        
00055   }
00056    t++; 
00057     pch = strtok (NULL, ",");
00058   }
00059   /*  wait(10);
00060     pc.printf("TDS=");
00061     async_port.puts("O,TDS,1\r");
00062     async_port.puts("O,EC,0\r");
00063     async_port.puts("R\r");
00064     wait(10);
00065     async_port.gets(A,6);
00066     pc.printf(A);
00067     pc.printf("\n\r");
00068     */
00069     
00070     
00071     }