7 #ifndef MAP27_DATALAYER_H
8 #define MAP27_DATALAYER_H
84 void link_request(uint8_t n1, uint8_t k, uint8_t version);
98 void link_transfer(uint8_t n_s, uint8_t ar, uint8_t* buf, uint16_t bufLen);
130 void link_establishment_timeout();
131 void retry_timeout();
132 void acknowledgement_timeout();
133 void activity_timeout();
134 void link_failure_detection_timeout();
137 void adjust_link_parameters(uint8_t n1, uint8_t k, uint8_t version);
138 void decrement_retransmission_counter();
139 void decrement_send_credit();
140 void delete_acknowledged_packets(uint8_t n_r);
141 void increment_send_state();
142 void initialise_variables();
143 void initialise_rs232_port();
144 void maximise_link_parameters();
145 void record_send_credit(uint8_t n_r, uint8_t n_k);
146 void rewind_packet_number(uint8_t n_r);
147 void set_retransmission_counter(uint8_t c1xo);
148 void store_acknowledged_rx_sequence_number(uint8_t n_r);
149 void store_packet(uint8_t* buf, uint16_t bufLen);
150 void store_receive_credit();
151 void update_receive_credit(uint8_t r_k);
153 void increment_receive_state();
154 void decrement_receive_credit();
157 bool acknowledgement_inside_window(uint8_t n_r);
158 bool all_transmitted_packets_acknowledged(uint8_t n_r);
159 bool immediate_reply_requested(uint8_t ar);
160 bool packet_out_of_sequence(uint8_t n_s);
161 bool packet_outside_window(uint8_t n);
162 bool receive_credit_available();
163 bool received_parameters_acceptable(uint8_t n1, uint8_t k, uint8_t version);
164 bool repeated_link_acknowledge(uint8_t n_r);
165 bool retransmission_count_zero();
166 bool send_credit_available();
170 virtual void output_link_failure();
171 virtual void output_packet_accepted();
172 virtual void output_packet_rejected();
173 virtual void output_network_layer_packet(uint8_t* buf, uint16_t bufLen);
176 virtual void output_link_request();
177 virtual void output_link_acknowledge();
178 virtual void output_link_transfer();
181 static void link_establishment_timer_callback_glue(
void* target);
182 static void retry_timer_callback_glue(
void* target);
183 static void acknowledgement_timer_callback_glue(
void* target);
184 static void activity_timer_callback_glue(
void* target);
185 static void link_failure_detection_timer_callback_glue(
void* target);
187 uint32_t calc_retry_timeout();
188 uint32_t calc_acknowledgement_timeout();
193 LINK_STATE_RESET_WAIT = 1,
194 LINK_STATE_LINK_WAIT,
202 LinkState _link_state;
205 uint8_t _maximum_length;
206 uint8_t _window_size;
211 uint8_t _receive_state;
212 uint8_t _receive_credit;
213 uint8_t _send_credit;
214 uint8_t _stored_acknowledged_rx_sequence_number;
215 uint8_t _stored_receive_credit;
216 uint8_t _retransmission_count;
219 uint8_t _second_last_n_r;
229 uint8_t _txQueueBuf[MAP27_MAX_MESSAGE_LEN][MAP27_WINDOW_SIZE];
230 uint8_t _txQueueBuflen[MAP27_WINDOW_SIZE];
231 uint8_t _txQueueLength;
Manage the Physical Layer of the Map27 protocol stack.
Definition: PhysicalLayer.h:37
bool isReady()
Definition: DataLayer.cpp:698
void link_request(uint8_t n1, uint8_t k, uint8_t version)
Definition: DataLayer.cpp:160
virtual void output_link_ready()
Outputs to Network Layer A2.2.7.
Definition: DataLayer.cpp:663
Map27NetworkLayer * networkLayer()
Definition: DataLayer.cpp:90
Manage the Data Layer of the Map27 protocol stack.
Definition: DataLayer.h:26
void network_layer_reset()
Definition: DataLayer.cpp:113
Manage the Network Layer of the Map27 protocol stack.
Definition: NetworkLayer.h:281
void setBaud(uint32_t baud)
Definition: DataLayer.cpp:95
void link_transfer(uint8_t n_s, uint8_t ar, uint8_t *buf, uint16_t bufLen)
Definition: DataLayer.cpp:279
void link_acknowledge(uint8_t n_r, uint8_t n_k)
Definition: DataLayer.cpp:204
Map27PhysicalLayer * physicalLayer()
Definition: DataLayer.cpp:80
void setPhysicalLayer(Map27PhysicalLayer *physicalLayer)
Definition: DataLayer.cpp:75
uint32_t baud()
Definition: DataLayer.cpp:100
Class for one-shot millisecond timers.
Definition: Timer.h:37
void setNetworkLayer(Map27NetworkLayer *networkLayer)
Definition: DataLayer.cpp:85
Map27DataLayer()
Constructor.
Definition: DataLayer.cpp:42
void power_on()
Definition: DataLayer.cpp:105
bool network_layer_packet(uint8_t *buf, uint16_t bufLen)
Definition: DataLayer.cpp:410
void poll()
Definition: DataLayer.cpp:64
void credit_value(uint8_t r_k)
Definition: DataLayer.cpp:118