For thermal pod
Dependencies: Hepta9axis HeptaBattery HeptaCamera_GPS HeptaTemp HeptaXbee SDFileSystem mbed
main.cpp@19:58fb3ab94fbe, 2017-09-09 (annotated)
- Committer:
- HEPTA
- Date:
- Sat Sep 09 06:58:06 2017 +0000
- Revision:
- 19:58fb3ab94fbe
- Parent:
- 17:904bcb46a48d
- Child:
- 20:eb334313e2fe
Thermal Chamber Test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:bdbd3d6fc5d5 | 1 | #include "mbed.h" |
mbed_official | 0:bdbd3d6fc5d5 | 2 | #include "SDFileSystem.h" |
umeume | 2:1c5cdb2c3e0f | 3 | #include "HeptaXbee.h" |
umeume | 2:1c5cdb2c3e0f | 4 | #include "HeptaTemp.h" |
umeume | 2:1c5cdb2c3e0f | 5 | |
umeume | 2:1c5cdb2c3e0f | 6 | Serial pc(USBTX,USBRX); |
HEPTA | 9:942eb6e8c117 | 7 | SDFileSystem sd(p5, p6, p7, p8, "sd"); |
umeume | 2:1c5cdb2c3e0f | 8 | HeptaXbee xbee(p9,p10); |
HEPTA | 16:83536ace57fb | 9 | HeptaTemp temper(p17); |
HEPTA | 19:58fb3ab94fbe | 10 | Timer tt; |
umeume | 5:c5ccb1b07e8f | 11 | |
umeume | 2:1c5cdb2c3e0f | 12 | int main() |
umeume | 2:1c5cdb2c3e0f | 13 | { |
HEPTA | 16:83536ace57fb | 14 | int rcmd=0,cmdflag=0; |
HEPTA | 16:83536ace57fb | 15 | float voltage; |
HEPTA | 16:83536ace57fb | 16 | mkdir("/sd/mydir", 0777); |
HEPTA | 16:83536ace57fb | 17 | while(1) { |
HEPTA | 16:83536ace57fb | 18 | wait(1.0); |
HEPTA | 16:83536ace57fb | 19 | xbee.xbee_recieve(&rcmd,&cmdflag); |
HEPTA | 16:83536ace57fb | 20 | pc.printf("rcmd=%d, cmdflag=%d\r\n",rcmd, cmdflag); |
HEPTA | 16:83536ace57fb | 21 | if (cmdflag == 1) { |
HEPTA | 16:83536ace57fb | 22 | pc.printf("Command Get %d\r\n",rcmd); |
HEPTA | 16:83536ace57fb | 23 | if(rcmd == 'a') { |
HEPTA | 16:83536ace57fb | 24 | while(1) { |
HEPTA | 19:58fb3ab94fbe | 25 | tt.start(); |
HEPTA | 19:58fb3ab94fbe | 26 | FILE *fp = fopen("/sd/mydir/test_thermal.csv", "a"); |
HEPTA | 16:83536ace57fb | 27 | temper.temp_sensing_vol(&voltage); |
HEPTA | 19:58fb3ab94fbe | 28 | xbee.printf("Volt = %f\r\n",voltage); |
HEPTA | 16:83536ace57fb | 29 | fprintf(fp,"%f\r\n",voltage); |
HEPTA | 16:83536ace57fb | 30 | fclose(fp); |
HEPTA | 19:58fb3ab94fbe | 31 | wait(0.45242); |
HEPTA | 19:58fb3ab94fbe | 32 | float timer = tt.read(); |
HEPTA | 19:58fb3ab94fbe | 33 | xbee.printf("Time =%f\r\n",timer); |
HEPTA | 19:58fb3ab94fbe | 34 | tt.stop(); |
HEPTA | 19:58fb3ab94fbe | 35 | tt.reset(); |
HEPTA | 16:83536ace57fb | 36 | } |
HEPTA | 16:83536ace57fb | 37 | xbee.initialize(); |
HEPTA | 16:83536ace57fb | 38 | } |
HEPTA | 16:83536ace57fb | 39 | if(rcmd == 'b') { |
HEPTA | 16:83536ace57fb | 40 | pc.printf("SD test Mode\r\n"); |
HEPTA | 17:904bcb46a48d | 41 | FILE *fp = fopen("/sd/mydir/myfile.txt", "w"); |
HEPTA | 16:83536ace57fb | 42 | if(fp == NULL) { |
HEPTA | 16:83536ace57fb | 43 | pc.printf("Could not open file for write\r\n"); |
HEPTA | 16:83536ace57fb | 44 | } else { |
HEPTA | 16:83536ace57fb | 45 | fprintf(fp, "\n\rHello World!\n\r"); |
HEPTA | 16:83536ace57fb | 46 | pc.printf("SD Check Complete!!\r\n"); |
HEPTA | 16:83536ace57fb | 47 | fclose(fp); |
HEPTA | 19:58fb3ab94fbe | 48 | remove("/sd/mydir/test_thermal.csv"); |
HEPTA | 16:83536ace57fb | 49 | } |
HEPTA | 16:83536ace57fb | 50 | xbee.initialize(); |
HEPTA | 16:83536ace57fb | 51 | } |
HEPTA | 16:83536ace57fb | 52 | } |
HEPTA | 16:83536ace57fb | 53 | } |
umeume | 2:1c5cdb2c3e0f | 54 | } |