-
Notifications
You must be signed in to change notification settings - Fork 0
/
ICanInterface.cs
43 lines (34 loc) · 1.32 KB
/
ICanInterface.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CypressRobotics.CAN
{
public delegate void OnCANMessageReceivedHandler(object sender, CANMessage e);
public interface ICanInterface
{
byte Address { get; set; }
/// <summary>
/// Initialize any supporting hardware
/// </summary>
/// <returns>True if initialization succeeded, otherwise false.</returns>
bool Initialize();
Task<bool> InitializeAsync();
/// <summary>
/// Send bytes synchronously via CAN.
/// </summary>
/// <param name="address">Address to send bytes to.</param>
/// <param name="payload">Bytes to send. Maximum 8 bytes.</param>
/// <returns>True if send appears to have succeeded, otherwise false.</returns>
bool SendRawMessage(uint address, byte[] payload);
bool SendBytes(byte target, byte[] payload, byte messageType = 0);
bool SendMessage(CANMessage message);
/// <summary>
/// Synchronously read from CAN device. Will block until data is received.
/// </summary>
/// <returns>Bytes received from CAN.</returns>
CANMessage ReceiveMessage();
event OnCANMessageReceivedHandler OnCANMessageReceived;
}
}