Deprecated Ringbuf_Alloc, and replaced with Ringbuf_Data_Peek() and Ringbuf_Data_Put() functions. Ringbuf_Alloc() was not interrupt or thread safe.
This commit is contained in:
@@ -113,11 +113,12 @@ void bacnet_task_timed(
|
||||
|
||||
pdu_len = dlmstp_receive(&src, &PDUBuffer[0], sizeof(PDUBuffer), 5);
|
||||
if (pdu_len) {
|
||||
pkt = (struct mstp_rx_packet *) Ringbuf_Alloc(&Receive_Queue);
|
||||
pkt = (struct mstp_rx_packet *) Ringbuf_Data_Peek(&Receive_Queue);
|
||||
if (pkt) {
|
||||
memcpy(pkt->buffer, PDUBuffer, MAX_MPDU);
|
||||
bacnet_address_copy(&pkt->src, &src);
|
||||
pkt->length = pdu_len;
|
||||
Ringbuf_Data_Put(&Receive_Queue, pkt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,7 +134,7 @@ static void bacnet_test_task(void)
|
||||
uint32_t instance;
|
||||
float float_value;
|
||||
uint16_t adc_value;
|
||||
|
||||
|
||||
instance = Analog_Input_Index_To_Instance(index);
|
||||
if (!Analog_Input_Out_Of_Service(instance)) {
|
||||
adc_value = adc_result_12bit(index);
|
||||
@@ -194,7 +195,7 @@ void bacnet_task(void)
|
||||
void bacnet_init(void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
|
||||
Ringbuf_Init(&Receive_Queue, (uint8_t *) & Receive_Buffer,
|
||||
sizeof(struct mstp_rx_packet), MSTP_RECEIVE_PACKET_COUNT);
|
||||
dlmstp_init(NULL);
|
||||
@@ -229,5 +230,5 @@ void bacnet_init(void)
|
||||
Analog_Input_Units_Set(
|
||||
Analog_Input_Index_To_Instance(i),
|
||||
UNITS_PERCENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1267,7 +1267,7 @@ int dlmstp_send_pdu(BACNET_ADDRESS * dest, /* destination address */
|
||||
struct mstp_pdu_packet *pkt;
|
||||
uint16_t i = 0;
|
||||
|
||||
pkt = (struct mstp_pdu_packet *) Ringbuf_Alloc(&PDU_Queue);
|
||||
pkt = (struct mstp_pdu_packet *) Ringbuf_Data_Peek(&PDU_Queue);
|
||||
if (pkt) {
|
||||
pkt->data_expecting_reply = npdu_data->data_expecting_reply;
|
||||
for (i = 0; i < pdu_len; i++) {
|
||||
@@ -1279,7 +1279,9 @@ int dlmstp_send_pdu(BACNET_ADDRESS * dest, /* destination address */
|
||||
} else {
|
||||
pkt->destination_mac = dest->mac[0];
|
||||
}
|
||||
bytes_sent = pdu_len;
|
||||
if (Ringbuf_Data_Put(&PDU_Queue, pkt)) {
|
||||
bytes_sent = pdu_len;
|
||||
}
|
||||
}
|
||||
|
||||
return bytes_sent;
|
||||
@@ -1294,13 +1296,13 @@ int dlmstp_send_pdu(BACNET_ADDRESS * dest, /* destination address */
|
||||
* @param max_pdu [in] - the size of the PDU buffer
|
||||
* @param timeout [in] - the number of milliseconds to wait for a packet
|
||||
*
|
||||
* @return Return the length of the packet
|
||||
* @return Return the length of the packet
|
||||
*/
|
||||
uint16_t dlmstp_receive(BACNET_ADDRESS * src,
|
||||
uint8_t * pdu,
|
||||
uint16_t max_pdu,
|
||||
unsigned timeout)
|
||||
{
|
||||
{
|
||||
uint16_t pdu_len = 0; /* return value */
|
||||
bool transmitting = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user