Skip to content

Commit

Permalink
Merge pull request #258 from WildernessLabs/feature/can-errors
Browse files Browse the repository at this point in the history
added can error info
  • Loading branch information
adrianstevens authored Aug 20, 2024
2 parents 814bafb + 390f6be commit 73dbf57
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,90 +8,90 @@ public enum CanBitrate
/// <summary>
/// 5 kbps CAN bitrate.
/// </summary>
Can_5kbps,
Can_5kbps = 5_000,

/// <summary>
/// 10 kbps CAN bitrate.
/// </summary>
Can_10kbps,
Can_10kbps = 10_000,

/// <summary>
/// 20 kbps CAN bitrate.
/// </summary>
Can_20kbps,
Can_20kbps = 20_000,

/// <summary>
/// 33 kbps CAN bitrate.
/// </summary>
Can_33kbps,
Can_33kbps = 33_000,

/// <summary>
/// 40 kbps CAN bitrate.
/// </summary>
Can_40kbps,
Can_40kbps = 40_000,

/// <summary>
/// 47 kbps CAN bitrate.
/// </summary>
Can_47kbps,
Can_47kbps = 47_000,

/// <summary>
/// 50 kbps CAN bitrate.
/// </summary>
Can_50kbps,
Can_50kbps = 50_000,

/// <summary>
/// 80 kbps CAN bitrate.
/// </summary>
Can_80kbps,
Can_80kbps = 80_000,

/// <summary>
/// 83 kbps CAN bitrate.
/// </summary>
Can_83kbps,
Can_83kbps = 83_000,

/// <summary>
/// 95 kbps CAN bitrate.
/// </summary>
Can_95kbps,
Can_95kbps = 95_000,

/// <summary>
/// 100 kbps CAN bitrate.
/// </summary>
Can_100kbps,
Can_100kbps = 100_000,

/// <summary>
/// 125 kbps CAN bitrate.
/// </summary>
Can_125kbps,
Can_125kbps = 125_000,

/// <summary>
/// 200 kbps CAN bitrate.
/// </summary>
Can_200kbps,
Can_200kbps = 200_000,

/// <summary>
/// 250 kbps CAN bitrate.
/// </summary>
Can_250kbps,
Can_250kbps = 250_000,

/// <summary>
/// 500 kbps CAN bitrate.
/// </summary>
Can_500kbps,
Can_500kbps = 500_000,

/// <summary>
/// 800 kbps CAN bitrate.
/// </summary>
Can_800kbps,
Can_800kbps = 800_000,

/// <summary>
/// 1 Mbps CAN bitrate.
/// </summary>
Can_1Mbps,
Can_1Mbps = 1_000_000,

/// <summary>
/// Flexible Data Rate
/// </summary>
Can_FD,
Can_FD = -1,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Meadow.Hardware;

/// <summary>
/// Represents CAN bus error information
/// </summary>
public class CanErrorInfo
{
/// <summary>
/// The number of transmit errors detected
/// </summary>
public byte TransmitErrorCount { get; set; }
/// <summary>
/// The number of receive errors detected
/// </summary>
public byte ReceiveErrorCount { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ namespace Meadow.Hardware;
public interface ICanBus
{
/// <summary>
/// Gets or sets the bus bit rate
/// Raised when a CAN frame is received.
/// </summary>
CanBitrate BitRate { get; set; }
event EventHandler<ICanFrame>? FrameReceived;

/// <summary>
/// Occurs when a CAN frame is received.
/// Raised when a bus error occurs
/// </summary>
event EventHandler<ICanFrame>? FrameReceived;
event EventHandler<CanErrorInfo>? BusError;

/// <summary>
/// Gets or sets the bus bit rate
/// </summary>
CanBitrate BitRate { get; set; }

/// <summary>
/// Writes a CAN frame to the specified buffer.
Expand Down

0 comments on commit 73dbf57

Please sign in to comment.