source: firmware/FSC/src/parser.c@ 10669

Last change on this file since 10669 was 10667, checked in by neise, 14 years ago
File size: 2.5 KB
Line 
1#include "parser.h"
2#include "output.h"
3#include "application.h"
4#include "usart.h"
5// this method parses the data,
6// which came in via USART
7// later it might as well parse the data from ethernet.
8void parse_ascii() {
9 usart_rx_buffer[USART_RX_BUFFER_SIZE-1] = 0;
10 usart_write_str((pU08)"got:");
11 usart_write_str(usart_rx_buffer);
12
13// look at first byte
14// I hope, I can manage to use one byte commands
15 switch (usart_rx_buffer[0]) {
16 case 'E': // AD7719 enable bitmaps may be set
17 set_ad7719_enable_register();
18 break;
19 case 'e': // ATmega internal ADC enable bitmaps may be set
20 // not supported yet.
21 set_adc_enable_register();
22 break;
23 case 'h':
24 usart_write_str((pU08)"\nheartbeat ");
25 heartbeat_enable = true;
26 if (usart_rx_buffer[1] == '0'){
27 heartbeat_enable = false;
28 usart_write_str((pU08)"off\n");
29 } else {
30 usart_write_str((pU08)"on\n");
31 }
32 break;
33 case 'G': // GET the Temperature channels, which are enabled
34 once_told_you = false;
35 for ( U08 i=0; i<CHANNEL_BITMAP; ++i ) {
36 ad7719_channels_ready[i]=0;
37 }
38 break;
39
40 case 'g': // GET the voltage/current/humidity channels, which are enabled
41 once_told_you = false;
42 for ( U08 i=0; i<V_BITMAP + I_BITMAP + H_BITMAP; ++i ) {
43 adc_channels_ready[i]=0;
44 }
45 break;
46
47 case 'P':
48 print_ad7719_nicely();
49 break;
50
51 case 'p':
52 print_adc_nicely();
53 break;
54
55 case 's':
56 print_status();
57 break;
58
59 case 'd':
60 usart_write_str((pU08)"\ndebug mode ");
61 debug_mode = true;
62 if (usart_rx_buffer[1] == '0'){
63 debug_mode = false;
64 usart_write_str((pU08)"off\n");
65 } else {
66 usart_write_str((pU08)"on\n");
67 }
68 break;
69 }
70
71
72 usart_write_str((pU08)"\nready?");
73 for (U08 i=0; i<USART_RX_BUFFER_SIZE; ++i)
74 usart_rx_buffer[i] = 0;
75}
76
77void parse_non_human_readable_input() {
78
79
80}
81
82// this guy checks, if an incoming byte is:
83// to be stored, because it belongs to a command
84// to be discarded, because something went wrong, and the bytemade no sense...
85// the end of a commmand, and so the 'real parser' may do his work.
86
87void incoming_byte_parser() {
88 static bool receiving_command = false;
89 U08 current_byte = UDR;
90
91 if (!receiving_command) {
92 switch (current_byte) {
93 case 0x01:
94 receiving_command = true;
95 break;
96 }
97 }
98
99 if (receiving_command)
100 {
101 usart_rx_buffer[usart_received_chars] = usart_last_char;
102 usart_received_chars++;
103 }
104
105
106}
Note: See TracBrowser for help on using the repository browser.