src/hp34comm.h

changeset 28
424d792fea4f
parent 21
9ffa9d727d80
child 37
07e8ca2bdf6d
equal deleted inserted replaced
27:8f2be7aaec00 28:424d792fea4f
1 #ifndef HP34COMM_H 1 #ifndef HP34COMM_H
2 #define HP34COMM_H 2 #define HP34COMM_H
3 3
4 #include "mbed.h" 4 #include <mbed.h>
5 #include "CircularBuffer.h" 5 #include <CircularBuffer.h>
6 6
7 /***** HP 34970A communication class ***/ 7 /***** HP 34970A communication class ***/
8 8
9 #define MAX_ERRS 10 9 #define MAX_ERRS 10
10 #define MAX_BUFF 16 10 #define MAX_BUFF 16
43 if (v > 0.0) 43 if (v > 0.0)
44 timeouter.attach(callback(this, &HPSerial::timeout), v); 44 timeouter.attach(callback(this, &HPSerial::timeout), v);
45 } 45 }
46 46
47 private: 47 private:
48 RawSerial serial; 48 UnbufferedSerial serial;
49 uint8_t buf[BUF_SIZE]; 49 uint8_t buf[BUF_SIZE];
50 uint8_t head; 50 uint8_t head;
51 CircularBuffer<CMD, 32> cmdbuf; 51 CircularBuffer<CMD, 32> cmdbuf;
52 unsigned long ncmd; 52 unsigned long ncmd;
53 unsigned int errs[MAX_ERRS]; 53 unsigned int errs[MAX_ERRS];
101 state_t do_state_initial(uint8_t c=0x00); 101 state_t do_state_initial(uint8_t c=0x00);
102 state_t do_state_command(uint8_t c); 102 state_t do_state_command(uint8_t c);
103 state_t do_state_payload_size(uint8_t c); 103 state_t do_state_payload_size(uint8_t c);
104 state_t do_state_payload(uint8_t c); 104 state_t do_state_payload(uint8_t c);
105 state_t do_state_sending(uint8_t c=0x00); 105 state_t do_state_sending(uint8_t c=0x00);
106 state_t do_state_eot(uint8_t c=0x00); 106 state_t do_state_eot(uint8_t c=0x55);
107 107
108 void send_ack(uint8_t c); 108 void send_ack(uint8_t c);
109 109
110 typedef state_t(HPSerial::*statemethod)(uint8_t c); 110 typedef state_t(HPSerial::*statemethod)(uint8_t c);
111 static statemethod state_table[NUM_STATES]; 111 static statemethod state_table[NUM_STATES];

mercurial