Skip to content

Commit ab253c1

Browse files
committed
communication: throw an ArgumentException if data to send is greater than 255
Signed-off-by: Diego Escalona <diego.escalona@digi.com>
1 parent 81bc8d6 commit ab253c1

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

XBeeLibrary.Core/AbstractXBeeDevice.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019, Digi International Inc.
2+
* Copyright 2019, 2020, Digi International Inc.
33
* Copyright 2014, 2015, Sébastien Rault.
44
*
55
* Permission to use, copy, modify, and/or distribute this software for any
@@ -2076,6 +2076,7 @@ protected void ForceDisassociate()
20762076
/// <param name="destinationInterface">Destination XBee local interface.</param>
20772077
/// <param name="data">Data to send.</param>
20782078
/// <exception cref="ArgumentException">If the destination interface is unknown.</exception>
2079+
/// <exception cref="ArgumentException">If data length is greater than 255 bytes.</exception>
20792080
/// <exception cref="XBeeException">If there is any XBee related error sending the User
20802081
/// Data Relay.</exception>
20812082
/// <seealso cref="XBeeLocalInterface"/>
@@ -2086,6 +2087,8 @@ protected void SendUserDataRelay(XBeeLocalInterface destinationInterface, byte[]
20862087
{
20872088
if (destinationInterface == XBeeLocalInterface.UNKNOWN)
20882089
throw new ArgumentException("Destination interface cannot be unknown.");
2090+
if (data.Length > 255)
2091+
throw new ArgumentException("Data length cannot be greater than 255 bytes.");
20892092

20902093
// Check if device is remote.
20912094
if (IsRemote)
@@ -2103,6 +2106,7 @@ protected void SendUserDataRelay(XBeeLocalInterface destinationInterface, byte[]
21032106
/// Sends the given data to the XBee Bluetooth interface in a User Data Relay frame.
21042107
/// </summary>
21052108
/// <param name="data">Data to send.</param>
2109+
/// <exception cref="ArgumentException">If data length is greater than 255 bytes.</exception>
21062110
/// <exception cref="XBeeException">If there is any XBee related error sending the Bluetooth
21072111
/// data.</exception>
21082112
/// <seealso cref="SendMicroPythonData(byte[])"/>
@@ -2117,6 +2121,7 @@ protected void SendBluetoothData(byte[] data)
21172121
/// Sends the given data to the XBee MicroPython interface in a User Data Relay frame.
21182122
/// </summary>
21192123
/// <param name="data">Data to send.</param>
2124+
/// <exception cref="ArgumentException">If data length is greater than 255 bytes.</exception>
21202125
/// <exception cref="XBeeException">If there is any XBee related error sending the
21212126
/// MicroPython data.</exception>
21222127
/// <seealso cref="SendBluetoothData(byte[])"/>
@@ -2131,6 +2136,7 @@ protected void SendMicroPythonData(byte[] data)
21312136
/// Sends the given data to the XBee serial interface in a User Data Relay frame.
21322137
/// </summary>
21332138
/// <param name="data">Data to send.</param>
2139+
/// <exception cref="ArgumentException">If data length is greater than 255 bytes.</exception>
21342140
/// <exception cref="XBeeException">If there is any XBee related error sending the serial
21352141
/// data.</exception>
21362142
/// <seealso cref="SendBluetoothData(byte[])"/>

XBeeLibrary.Core/IPDevice.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019, Digi International Inc.
2+
* Copyright 2019, 2020, Digi International Inc.
33
*
44
* Permission to use, copy, modify, and/or distribute this software for any
55
* purpose with or without fee is hereby granted, provided that the above
@@ -339,6 +339,7 @@ public override void ReadDeviceInfo()
339339
/// <param name="destinationInterface">Destination XBee local interface.</param>
340340
/// <param name="data">Data to send.</param>
341341
/// <exception cref="ArgumentException">If the destination interface is unknown.</exception>
342+
/// <exception cref="ArgumentException">If data length is greater than 255 bytes.</exception>
342343
/// <exception cref="XBeeException">If there is any XBee related error sending the User
343344
/// Data Relay.</exception>
344345
/// <seealso cref="XBeeLocalInterface"/>
@@ -353,6 +354,7 @@ public override void ReadDeviceInfo()
353354
/// Sends the given data to the XBee Bluetooth interface in a User Data Relay frame.
354355
/// </summary>
355356
/// <param name="data">Data to send.</param>
357+
/// <exception cref="ArgumentException">If data length is greater than 255 bytes.</exception>
356358
/// <exception cref="XBeeException">If there is any XBee related error sending the Bluetooth
357359
/// data.</exception>
358360
/// <seealso cref="SendMicroPythonData(byte[])"/>
@@ -366,6 +368,7 @@ public override void ReadDeviceInfo()
366368
/// Sends the given data to the XBee MicroPython interface in a User Data Relay frame.
367369
/// </summary>
368370
/// <param name="data">Data to send.</param>
371+
/// <exception cref="ArgumentException">If data length is greater than 255 bytes.</exception>
369372
/// <exception cref="XBeeException">If there is any XBee related error sending the
370373
/// MicroPython data.</exception>
371374
/// <seealso cref="SendBluetoothData(byte[])"/>

XBeeLibrary.Core/XBeeDevice.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019, Digi International Inc.
2+
* Copyright 2019, 2020, Digi International Inc.
33
* Copyright 2014, 2015, Sébastien Rault.
44
*
55
* Permission to use, copy, modify, and/or distribute this software for any
@@ -542,6 +542,7 @@ protected XBeeDevice(IConnectionInterface connectionInterface)
542542
/// <param name="destinationInterface">Destination XBee local interface.</param>
543543
/// <param name="data">Data to send.</param>
544544
/// <exception cref="ArgumentException">If the destination interface is unknown.</exception>
545+
/// <exception cref="ArgumentException">If data length is greater than 255 bytes.</exception>
545546
/// <exception cref="XBeeException">If there is any XBee related error sending the User
546547
/// Data Relay.</exception>
547548
/// <seealso cref="XBeeLocalInterface"/>
@@ -556,6 +557,7 @@ protected XBeeDevice(IConnectionInterface connectionInterface)
556557
/// Sends the given data to the XBee Bluetooth interface in a User Data Relay frame.
557558
/// </summary>
558559
/// <param name="data">Data to send.</param>
560+
/// <exception cref="ArgumentException">If data length is greater than 255 bytes.</exception>
559561
/// <exception cref="XBeeException">If there is any XBee related error sending the Bluetooth
560562
/// data.</exception>
561563
/// <seealso cref="SendMicroPythonData(byte[])"/>
@@ -569,6 +571,7 @@ protected XBeeDevice(IConnectionInterface connectionInterface)
569571
/// Sends the given data to the XBee MicroPython interface in a User Data Relay frame.
570572
/// </summary>
571573
/// <param name="data">Data to send.</param>
574+
/// <exception cref="ArgumentException">If data length is greater than 255 bytes.</exception>
572575
/// <exception cref="XBeeException">If there is any XBee related error sending the
573576
/// MicroPython data.</exception>
574577
/// <seealso cref="SendBluetoothData(byte[])"/>

XBeeLibrary.Xamarin/XBeeBLEDevice.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019, Digi International Inc.
2+
* Copyright 2019, 2020, Digi International Inc.
33
*
44
* Permission to use, copy, modify, and/or distribute this software for any
55
* purpose with or without fee is hereby granted, provided that the above
@@ -427,6 +427,7 @@ public override void Reset()
427427
/// <param name="destinationInterface">Destination XBee local interface.</param>
428428
/// <param name="data">Data to send.</param>
429429
/// <exception cref="ArgumentException">If the destination interface is unknown.</exception>
430+
/// <exception cref="ArgumentException">If data length is greater than 255 bytes.</exception>
430431
/// <exception cref="XBeeException">If there is any XBee related error sending the User
431432
/// Data Relay.</exception>
432433
/// <seealso cref="XBeeLocalInterface"/>
@@ -441,6 +442,7 @@ public override void Reset()
441442
/// Sends the given data to the XBee MicroPython interface in a User Data Relay frame.
442443
/// </summary>
443444
/// <param name="data">Data to send.</param>
445+
/// <exception cref="ArgumentException">If data length is greater than 255 bytes.</exception>
444446
/// <exception cref="XBeeException">If there is any XBee related error sending the
445447
/// MicroPython data.</exception>
446448
/// <seealso cref="SendSerialData(byte[])"/>
@@ -454,6 +456,7 @@ public override void Reset()
454456
/// Sends the given data to the XBee serial interface in a User Data Relay frame.
455457
/// </summary>
456458
/// <param name="data">Data to send.</param>
459+
/// <exception cref="ArgumentException">If data length is greater than 255 bytes.</exception>
457460
/// <exception cref="XBeeException">If there is any XBee related error sending the serial
458461
/// data.</exception>
459462
/// <seealso cref="SendMicroPythonData(byte[])"/>

0 commit comments

Comments
 (0)