U2004 ARINC 429 Module Dll Library
 
Loading...
Searching...
No Matches
U2004 Class Reference

The U2004 is an ARINC 429 Data Server made by Canaan Avionics. This .Dll controls the U2004 through USB connection, but there are options for direct connection through TCP/IP ports for versions of the U2004 that have an RJ-45. TCP/IP sort can also be added using the S2309 DataPanel and using it as an Ip Bridge(see CanvasConnect, and UsbConnect for U2004 connection options). More...

Data Structures

class  A429Record
 A429 Records are how words are communicated through this DLL. More...
 
class  PortStatus
 A type that is returned for indicating the port speed, state, and status. See More...
 
class  U2004Fault
 A429 Records are how words are communicated through this DLL. More...
 

Public Types

enum  FrameLayout : int {
  PAYLOAD_SIZE = 66 , INDEX = 2 , OP_CODE = 3 , SEQ_NUM = 4 ,
  CHECKSUM = 5 , IS_ASYNC = 6 , PAYLOAD_START = 7 , FRAME_SIZE = PAYLOAD_START + PAYLOAD_SIZE + 2
}
 FrameLayout is how a communication frame with the U2004 is established.
More...
 
enum  FrameByte : byte {
  FRAME = 0xA5 , FAULT_NO_PORT = 0x20 , FAULT_ARGUEMENT = 0x21 , FAULT_MISFRAME = 0x22 ,
  FAULT_CHECKSUM = 0x23 , FAULT_OPCODE = 0x24 , FAULT_TIMEOUT = 0x25 , FAIL_OPCODE = 0xFF ,
  IS_NUMBER = 0x02 , NO_FAULT = 0xAA
}
 FrameByte is are fault codes and other values specific for communicating a Frame. More...
 
enum  CommMode { NONE = 1 , USB_TO_U2004 = 2 , TCP_TO_U2004 = 4 , TCP_TO_PANEL = 3 }
 CommMode is a enumeration for determiniging how the Dll is communicating with the U2004. More...
 
enum  Opcode : byte {
  Initialize = 0x01 , Reset = 0x04 , SetDiscrete = 0x05 , ClearDiscrete = 0x06 ,
  ReadDiscrete = 0x07 , PortHs = 0x20 , PortLs = 0x21 , PutIsUniqueSdi = 0x10 ,
  PutParity = 0x11 , GetRecords = 0x12 , ScheduleTxWord = 0x13 , ScheduleTxWords = 0x14 ,
  UnScheduleTxWord = 0x15 , TxWord = 0x16 , UpdateTxWord = 0x17 , PortStart = 0x18 ,
  PortStop = 0x19 , GetRxWord = 0x30 , SetRxRate = 0x31 , ReportStatus = 0x51 ,
  AsyncMode = 0x52 , AsyncDone = 0x53 , AsyncRecords = 0x54 , CanvasCommand = 0x60
}
 Opcodes for communicating commands to the U2004 within a communication frame. More...
 
enum  A429Port : byte {
  RX0 = 0x10 , RX1 = 0x11 , RX2 = 0x12 , RX3 = 0x13 ,
  RX4 = 0x14 , RX5 = 0x15 , RX6 = 0x16 , RX7 = 0x17 ,
  TX0 = 0x18 , TX1 = 0x19 , TX2 = 0x1A , TX3 = 0x1B ,
  STATUS = 0x33
}
 Idenifies which U2003 is being communicated with by a command that needs a A429Port argument. More...
 
enum  A429Parity : byte { Odd = 1 , Even = 0 , None = 2 }
 ARINC 429 parity means that the 32nd bit of the A429 Word is overwritten as a word-check, to detect a badly received bit. Parity is used by a number of functions to either set the parity, meaning that a transmitter from the U2004 will automatically write parity to the 32nd bit before it is put onto the wire, or that the parity can be set for a receiver port, meaning that the receiver will ignore parity that is received from the wire if it is not received correctly. More...
 

Public Member Functions

bool UsbConnect (string port)
 Opens a USB Connection to a U2004.

 
bool CanvasConnect (string ip, int tcpPort)
 Instead of calling UsbConnect which would connect to a U2004 throught USB, CanvasConnect can be called to connect to a U2004 that is alread connected to a S2309 CANVAS. Calling Communicate will coordinate a frame through either Usb or Tcp, regardless of the connection method. Know that a U2004 should be put into Async mode any time it is being used with Canvas rather than in an embedded system. CanvasConnect will do this automatically by calling AsyncMode
 
byte Checksum (byte[] frame)
 Computes the expected checksum of the given frame.
 
List< A429RecordAsyncCommunicate ()
 Called by a worker thread periodically to get all of the updated records and other status when the U2004 is in "Asynchronous Mode". When in this mode, the U2004 will constantly service a port and return a buffer of new records when this called.
 
byte[] Communicate (byte[] frame, bool checksum=true)
 Communicates a single command to the U2004, either directly via USB (when Mode = USB_TO_U2004) or through TCP (when Mode = TCP_TO_PANEL). This function does most of the heavy-lifting communication-wise, and is called by other commands such as UpdateTxWord. Typically Communicate() doesn't need to be called by an interfacing application.
 
byte[] TcpCommunicate (byte[] frame, bool checksum=true)
 Sends and receives a frame without any additional discrimination through the TCP Connection. This function is typically only used by the Communicate function.
 
void Initialize (byte seq_num=0)
 Initializes a connected U2004 (which may still be performing tasks from a previous session). This function also updates the FirmwareVersion and DeviceID.
 
void Reset (byte seq_num=0)
 Full software reset of the U2004.
 
void AsyncMode (bool async_on, byte seq_num=0)
 Puts the U2004 into "Asynchronous Mode", meaning that it will constantly output A429Records through AsyncCommunicate. A code example is in AsyncCommunicate.
 
void SetDiscrete (uint mask, byte seq_num=0)
 Writes to the U2004 discrete outputs (such as GND_DISC_OUT_0). See DiscreteOutputs for a listing and mapping of these discretes, which can be passed into the mask argument. This function specifically clears a ground/open discrete state.
 
void ClearDiscrete (uint mask, byte seq_num=0)
 Writes to the U2004 discrete outputs (such as GND_DISC_OUT_0). See DiscreteOutputs for a listing and mapping of these discretes, which can be passed into the mask argument. This function specifically opens a ground/open discrete state.
 
uint ReadDiscrete (byte seq_num=0)
 Returns the state of discrete inputs to the U2004 (such as GND_DISC_IN_0, GND_DISC_IN_1, GND_DISC_IN_2) This function usually is used when UpdateStatus isn't called, because DiscreteInputs also provides the states inputs. Use ReadDiscrete(byte) if a blocking operation is needed to check the discrete input states.
 
void PortHs (A429Port port, byte seq_num=0)
 Sets an A429 port to High Speed (100kbs)
 
void PortLs (A429Port port, byte seq_num=0)
 Sets an A429 port to Low Speed (12.5kbs)
 
void PutIsUniqueSdi (A429Port port, uint word, bool is_unique_sdi, byte seq_num=0)
 IsUniqueSdi is a property that can be attached to an ARINC 429 word where it tells the U2004 how to handle Source Designation Index (SDI) fields. The SDI is the 9th and 10th bits of an ARINC 429 word (the first 8 bits being the A429 label). For most application, the SDI is somewhat irrelevant because there usually is only one SDI field transmitted on a bus (out of four possible SDI with two-bits). The SDI being received is known by the receiving system by knowing which system the port is wired to. However, some systems, such as Distance Measurement Systems (DME) use the SDI field to differentiate between different channels. This means that the SDI needs to be differentiated by the processing equipment. If IsUniqueSdi configured for a label, then the SDI and Label fields (the first 10 bits) are processed together and all four versions of each label are chached and processed independently.
 
void PutParity (A429Port port, uint word, A429Parity parity, byte seq_num=0)
 Provided a A429 word, tells the U2004 what parity to accept on receiving ports, and what parity to put out on transmitting ports (Odd, Even, None).
 
List< A429RecordGetRecords (A429Port port, byte count, byte seq_num=0)
 Gets a list of A429Records from the U2004 buffer.
 
bool ScheduleTxWord (A429Port port, uint word, ushort time, bool is_froze, byte seq_num=0)
 Puts a word into the transmit schedule at the specified time. Words in the schedule are transmittted autonomously and periodically by the U2004 without the need for any Host interaction. A transmit schedule is 2,777 words (for a High Speed bus) and 347 words (for a Low Speed bus), which represents all of the words that that can possibly be transmit in one second.

 
void ScheduleTxWords (A429Port port, uint word, ushort time, ushort rate, bool is_froze, byte seq_num=0)
 Puts a word into the transmit schedule at the specified time. Words in the schedule are transmittted autonomously and periodically by the U2004 without the need for any Host interaction. A transmit schedule is 2,777 words (for a High Speed bus) and 347 words (for a Low Speed bus), which represents all of the words that that can possibly be transmit in one second.

 
void UnScheduleTxWord (A429Port port, uint word, byte seq_num=0)
 Removes all instances of a word, specifcally the first 8-bit label of a word, from the transmit schedule.
 
void TxWord (A429Port port, uint word, byte seq_num=0)
 Puts a word to be transmitted when space in schedule is available.
 
void TxWord (A429Port port, List< uint > words, byte seq_num=0)
 Puts a list of words to be transmitted when space in schedule is available, but not that words that don;t fit into the frame are dropped if there is not room.
 
void UpdateTxWord (A429Port port, uint word, byte seq_num=0)
 Assuming that a A429 Word has been scheduled, and is actively being transmitted by the U2004, calling UpdateTxWord will update the word value that is in the schedule. It updates what is being transmitted. This also un-freezes words in the schedule if they were scheduled and expect fresh updates from the Host before transmit onto the wire.
 
void UpdateTxWord (A429Port port, List< uint > words, byte seq_num=0)
 Assuming that a A429 Word has been scheduled, and is actively being transmitted by the U2004, calling UpdateTxWord will update the word value that is in the schedule. It updates what is being transmitted. This also un-freezes words in the schedule if they were scheduled and expect fresh updates from the Host before transmit onto the wire. This call is more performant than the single uint call when scheduling many words.
 
void PortStart (A429Port port, byte seq_num=0)
 Starts the Tx or Rx Port.
 
void PortStop (A429Port port, byte seq_num=0)
 tops the Tx or Rx Port
 
uint GetRxWord (A429Port port, uint word, byte seq_num=0, bool get_fresh=true)
 Receives the A429 Rx word from the U2004 Cache. If the word has a set [expected] receive rate (put by SetRxRate), and if 'get_fresh' is True, then the last word received on the port will be returned. If 'get_fresh' is False, then the last word received matching the word (the 8-bit label) will be returned, even if it is stale. NOTE: this function requires a uint-32 to be passed in as the parameter, but only the 8 "label" bits will be used. That is the least significant 8 bits will be used and the most significant 24 are entirely ignored by this function.
 
List< uint > GetRxWords (A429Port port, List< uint > words, byte seq_num=0, bool get_fresh=true)
 Receives the A429 Rx word from the U2004 Cache. If the word has a set [expected] receive rate (put by SetRxRate), and if 'get_fresh' is True, then the last word received on the port will be returned. If 'get_fresh' is False, then the last word received matching the word (the 8-bit label) will be returned, even if it is stale.
 
void SetRxRate (A429Port port, uint word, ushort rate, byte seq_num=0)
 Sets the expected rate of an ARINC 429 word. This is used to determine if a received word is fresh or stale, meaning that it was received within twice the expected rate on average.

 
void ReportStatus (byte seq_num=0)
 Requests the U2004 status; all ports, all discretes, and the operating mode.
 
object SetWkn (string wkn, double value)
 Sets the value of a Well Known Name to the value provided for example SetWkn('TIME_TO_GO_BCD', 12.2) will set the value of 'TIME_TO_GO_BCD' to 12.2, to set a co-located non-WKN, use a collon to address that vlue. for example SetWkn('TIME_TO_GO_BCD:Sdi', 3) will set the Source Designation Index in the word that contains 'TIME_TO_GO_BCD' to 3. Note: Under the current implementation, this will always query the port that has had it's ICD set for the longest.
 
object SetWknString (string wkn, string value)
 Sets the value of a Well Known Name to the value provided for example SetWkn('TIME_TO_GO_BCD', 12.2) will set the value of 'TIME_TO_GO_BCD' to 12.2, to set a co-located non-WKN, use a collon to address that vlue. for example SetWkn('TIME_TO_GO_BCD:Sdi', 3) will set the Source Designation Index in the word that contains 'TIME_TO_GO_BCD' to 3.

 
object GetWkn (string wkn)
 Used to read the value of a Well Known Name. Under the current implementation, this will always query the port that has had it's ICD set for the longest.
 
object GetWknString (string wkn)
 This function is called by GetWkn, which should be used in place of this. 'GetWknString' can be used however for greater control over the command issued to the U2004.
 
bool LoadIcdFromPath (string absolute_path, string port, string a429Bus_name)
 This function provides a way to programatically load ICDs into canvas onto a particular port. Note, a ~5 second sleep call should be made following this call to allow canvas to finish loading the icd.
 

Data Fields

SerialPort CommPort
 Serial Port for Communicating directly with the U2004 through the USB/COM port adapter. The U2004 is an FTDI port and can be communicated with through FTD2XX_NET.dll, but also through a generic COM port. Rates up to 921600bps have been tested. Use UsbConnect to open communication using the optimum settings.
 
int TimeOut = 4000
 The amount of time (ms) for Communicate to wait for a frame from the U2004. If there is no response in that time, then the frame is received as null.
 
byte Index = 0
 The Index of this U2004 device. This Dll supports a single host and multiple U2004 interfaces. The Index can be used to direct which U2004 is communicated with.
 
CommMode Mode = CommMode.NONE
 The active mode that this U2004 instance is communicating via.
 
bool ComFailed = false
 True if there was a communication fault detected. Usually the device would need to be reconnector or re-instantiated, or there is fundamental fault. ComFailed is set when the communication frame received, wasn;t received in the correct format or length.
 
UInt32 FirmwareVersion = 0
 Firmware Version of the U2004, Updated on Initialize. This is hard-coded into the U2004. Canaan Avionics support software updates on this where required.
 
UInt32 DeviceID = 0
 A unique serial number Id of the U2004, Updated on Initialize. This is hard-coded into the U2004. Canaan Avionics support software updates on this where required.
 
bool AsyncModeActive = false
 This is set True if the U2004 is in "Asyncronous Mode". See AsyncMode.
 
UInt32 DiscreteInputs = 0
 These are the Discrete Input States (Gnd/Open) of the U2004, read after a UpdateStatus call.
This register can be read through a bool operation to get any one discrete, or read all together for all discretes.
 
UInt32 DiscreteOutputs = 0
 These are the Discrete Output States (Gnd/Open) of the U2004, read after a UpdateStatus call.
This register can be read through a bool operation to get any one discrete, or read all together for all discretes. These are mosfet-driven discretes that are set through ClearDiscrete and SetDiscrete calls.
 
List< PortStatusStatus = new List<PortStatus>()
 A list of all of the PortStatus. This whole list is updated each time UpdateStatus is called. This list may be iterated or searched with lynq to find the port status for an particular port.
 
byte[] ReceivedFrame = new byte[0]
 The last USB communication frame received after a DataReceivedHandler call-back event.
 

Detailed Description

The U2004 is an ARINC 429 Data Server made by Canaan Avionics. This .Dll controls the U2004 through USB connection, but there are options for direct connection through TCP/IP ports for versions of the U2004 that have an RJ-45. TCP/IP sort can also be added using the S2309 DataPanel and using it as an Ip Bridge(see CanvasConnect, and UsbConnect for U2004 connection options).

Creating and instance of a U2004 is accomplished as followed:

// create a new U2004
U2004 U2004_Hardware = new U2004_11_Dll_Library.U2004();
// open a connection to this device through USB
// note that the com port is an FTDI port, and can be found specifically using FTD2XX_NET.dll if it is not known. <br>
U2004_Hardware.UsbConnect("COM6");
The U2004 is an ARINC 429 Data Server made by Canaan Avionics. This .Dll controls the U2004 through U...
Definition U2004.cs:76
bool UsbConnect(string port)
Opens a USB Connection to a U2004.
Definition U2004.cs:648
Definition U2004.cs:30

Here is an example using python, for which pythonnet enables C# dll interfaces easily, using the similar conventions. In the example below, a connection is being made to the U2004 via the S2309 CANVAS application via TCP/IP connection. the 'pythonnet' package must be installed

"""socket and os support"""
import sys
import clr
""" reference the U2004 dll """
sys.path.append(r"C:\Absolute\Path\to\Folder\Containing\U2004\Dll")
clr.AddReference("U2004_11_Dll_Library")
""" create a new U2004 """
u2004 = U2004()
""" attempt to connect to the U2003, through S2309 at port 11076 (the default port) """
if not u2004.CanvasConnect(127.0.0.1, 11076):
print("ERROR")
exit(1)
bool CanvasConnect(string ip, int tcpPort)
Instead of calling UsbConnect which would connect to a U2004 throught USB, CanvasConnect can be calle...
Definition U2004.cs:822

Member Enumeration Documentation

◆ A429Parity

enum A429Parity : byte

ARINC 429 parity means that the 32nd bit of the A429 Word is overwritten as a word-check, to detect a badly received bit. Parity is used by a number of functions to either set the parity, meaning that a transmitter from the U2004 will automatically write parity to the 32nd bit before it is put onto the wire, or that the parity can be set for a receiver port, meaning that the receiver will ignore parity that is received from the wire if it is not received correctly.

Enumerator
Odd 

Odd number of 1's bits in the 32-bit word.

Even 

Even number of 1's bits in the 32-bit word.

None 

Parity is not enforced, and number of bits can be set and the 32nd bit can be used for other things.

◆ A429Port

enum A429Port : byte

Idenifies which U2003 is being communicated with by a command that needs a A429Port argument.

For example, the following line starts data transmit operations on a TX port:

U2004_Hardware.PortStart(U2004.A429Port.TX0);
A429Port
Idenifies which U2003 is being communicated with by a command that needs a A429Port argument.
Definition U2004.cs:310
Enumerator
RX0 

0x10

RX1 

0x11

RX2 

0x12

RX3 

0x13

RX4 

0x14

RX5 

0x15

RX6 

0x16

RX7 

0x17

TX0 

0x18

TX1 

0x19

TX2 

0x1A

TX3 

0x1B

STATUS 

0x33

◆ CommMode

enum CommMode

CommMode is a enumeration for determiniging how the Dll is communicating with the U2004.

Enumerator
NONE 

Note Connected to anything ///.

USB_TO_U2004 

USB/Serial communication directly to the U2004 from this host computer.

TCP_TO_U2004 

TCP communication directly to the U2004, for U2004 devices that have an RJ-45 connector and a connection to a network.

TCP_TO_PANEL 

Communicates to the U2004 through a S2309 CANVAS Application, which posts a TCP socket via port (default is 11076)

◆ FrameByte

enum FrameByte : byte

FrameByte is are fault codes and other values specific for communicating a Frame.

Enumerator
FRAME 

0xA5

FAULT_NO_PORT 

0x20

FAULT_ARGUEMENT 

0x21

FAULT_MISFRAME 

0x22

FAULT_CHECKSUM 

0x23

FAULT_OPCODE 

0x24

FAULT_TIMEOUT 

0x25

FAIL_OPCODE 

0xFF

IS_NUMBER 

0x02

NO_FAULT 

0xAA

◆ FrameLayout

enum FrameLayout : int

FrameLayout is how a communication frame with the U2004 is established.

Enumerator
PAYLOAD_SIZE 

66

INDEX 

2

OP_CODE 

3

SEQ_NUM 

4

CHECKSUM 

5

IS_ASYNC 

6

PAYLOAD_START 

7

FRAME_SIZE 

PAYLOAD_START + PAYLOAD_SIZE + 2.

◆ Opcode

enum Opcode : byte

Opcodes for communicating commands to the U2004 within a communication frame.

Enumerator
Initialize 

0x01

Reset 

0x04

SetDiscrete 

0x05

ClearDiscrete 

0x06

ReadDiscrete 

0x07

PortHs 

0x20

PortLs 

0x21

PutIsUniqueSdi 

0x10

PutParity 

0x11

GetRecords 

0x12

ScheduleTxWord 

0x13

ScheduleTxWords 

0x14

UnScheduleTxWord 

0x15

TxWord 

0x16

UpdateTxWord 

0x17

PortStart 

0x18

PortStop 

0x19

GetRxWord 

0x30

SetRxRate 

0x31

ReportStatus 

0x51

AsyncMode 

0x52

AsyncDone 

0x53

AsyncRecords 

0x54

CanvasCommand 

0x60

Member Function Documentation

◆ AsyncCommunicate()

List< A429Record > AsyncCommunicate ( )
inline

Called by a worker thread periodically to get all of the updated records and other status when the U2004 is in "Asynchronous Mode". When in this mode, the U2004 will constantly service a port and return a buffer of new records when this called.

Here is an example worker and async operation

main()
{
// start a data worker
Thread dataWkr = new Thread(new ThreadStart(DataWorker));
dataWkr.IsBackground = true;
dataWkr.Start();
// put into async mode, as to constantly report
U2004_Hardware.AsyncMode(true);
}
// Constant background worker
public void DataWorker()
{
DateTime UiTime = DateTime.Now;
while (true) // Constant loop
{
Thread.Sleep(25);
// get data from the USB
if (U2004_Hardware.CommPort != null)
{
if (U2004_Hardware.CommPort.IsOpen)
{
// get new A429Records
foreach (U2004.A429Record nRec in U2004_Hardware.AsyncCommunicate())
{
// [process each A429Record here in your application]
}
}
}
}
}
A429 Records are how words are communicated through this DLL.
Definition U2004.cs:395

◆ AsyncMode()

void AsyncMode ( bool  async_on,
byte  seq_num = 0 
)
inline

Puts the U2004 into "Asynchronous Mode", meaning that it will constantly output A429Records through AsyncCommunicate. A code example is in AsyncCommunicate.

Here is the call graph for this function:

◆ CanvasConnect()

bool CanvasConnect ( string  ip,
int  tcpPort 
)
inline

Instead of calling UsbConnect which would connect to a U2004 throught USB, CanvasConnect can be called to connect to a U2004 that is alread connected to a S2309 CANVAS. Calling Communicate will coordinate a frame through either Usb or Tcp, regardless of the connection method. Know that a U2004 should be put into Async mode any time it is being used with Canvas rather than in an embedded system. CanvasConnect will do this automatically by calling AsyncMode

Here is an example in python, using CanvasConnect to esablish communication with a S2309 CANVAS

"""socket and os support"""
import sys
import clr
""" reference the U2004 dll """
sys.path.append(r"C:\Absolute\Path\to\Folder\Containing\U2004\Dll")
clr.AddReference("U2004_11_Dll_Library")
""" create a new U2004 """
u2004 = U2004()
""" attempt to connect to the U2003, through S2309 at port 11076 (the default port) """
if not u2004.CanvasConnect(127.0.0.1, 11076):
print("ERROR")
exit(1)

◆ Checksum()

byte Checksum ( byte[]  frame)
inline

Computes the expected checksum of the given frame.

◆ ClearDiscrete()

void ClearDiscrete ( uint  mask,
byte  seq_num = 0 
)
inline

Writes to the U2004 discrete outputs (such as GND_DISC_OUT_0). See DiscreteOutputs for a listing and mapping of these discretes, which can be passed into the mask argument. This function specifically opens a ground/open discrete state.

Here is an example using python:

""" map a discrete to a variable """
GND_DISC_OUT_0 = 0x01
GND_DISC_OUT_7 = 0x80
""" set both discretes, GND_DISC_OUT_0 and GND_DISC_OUT_7 """
U2004_Hardware.ClearDiscrete(GND_DISC_OUT_0 | GND_DISC_OUT_7)
Here is the call graph for this function:

◆ Communicate()

byte[] Communicate ( byte[]  frame,
bool  checksum = true 
)
inline

Communicates a single command to the U2004, either directly via USB (when Mode = USB_TO_U2004) or through TCP (when Mode = TCP_TO_PANEL). This function does most of the heavy-lifting communication-wise, and is called by other commands such as UpdateTxWord. Typically Communicate() doesn't need to be called by an interfacing application.

Returns
The return is expected to be in the context of the communicated frame. For example, GetRecords calls Communicate() and it returns a buffer of A429Records.
Here is the call graph for this function:

◆ GetRecords()

List< A429Record > GetRecords ( A429Port  port,
byte  count,
byte  seq_num = 0 
)
inline

Gets a list of A429Records from the U2004 buffer.

Here is the call graph for this function:

◆ GetRxWord()

uint GetRxWord ( A429Port  port,
uint  word,
byte  seq_num = 0,
bool  get_fresh = true 
)
inline

Receives the A429 Rx word from the U2004 Cache. If the word has a set [expected] receive rate (put by SetRxRate), and if 'get_fresh' is True, then the last word received on the port will be returned. If 'get_fresh' is False, then the last word received matching the word (the 8-bit label) will be returned, even if it is stale. NOTE: this function requires a uint-32 to be passed in as the parameter, but only the 8 "label" bits will be used. That is the least significant 8 bits will be used and the most significant 24 are entirely ignored by this function.

Here is an example using python where multiple words are read on the same port:

u2004.PortLs(U2004.A429Port.RX1)
u2004.PortStart(U2004.A429Port.RX1)
ReceivedWordA = u2004.GetRxWord(U2004.A429Port.RX2, 0x00000088)
ReceivedWordB = u2004.GetRxWord(U2004.A429Port.RX2, 0x000000FF)
Here is the call graph for this function:

◆ GetRxWords()

List< uint > GetRxWords ( A429Port  port,
List< uint >  words,
byte  seq_num = 0,
bool  get_fresh = true 
)
inline

Receives the A429 Rx word from the U2004 Cache. If the word has a set [expected] receive rate (put by SetRxRate), and if 'get_fresh' is True, then the last word received on the port will be returned. If 'get_fresh' is False, then the last word received matching the word (the 8-bit label) will be returned, even if it is stale.

This function is like GetRxWord except a list of words may be sent. Note that if the list is too big, then only words that fit into a communiction frame will be processed.

///

Here is the call graph for this function:

◆ GetWkn()

object GetWkn ( string  wkn)
inline

Used to read the value of a Well Known Name. Under the current implementation, this will always query the port that has had it's ICD set for the longest.

Here is an example using python:

gottenValue = u2004.GetWkn(MAGNETIC_HEADING)
print(type(gottenValue) + str(gottenValue))

◆ GetWknString()

object GetWknString ( string  wkn)
inline

This function is called by GetWkn, which should be used in place of this. 'GetWknString' can be used however for greater control over the command issued to the U2004.

◆ Initialize()

void Initialize ( byte  seq_num = 0)
inline

Initializes a connected U2004 (which may still be performing tasks from a previous session). This function also updates the FirmwareVersion and DeviceID.

Here is the call graph for this function:

◆ LoadIcdFromPath()

bool LoadIcdFromPath ( string  absolute_path,
string  port,
string  a429Bus_name 
)
inline

This function provides a way to programatically load ICDs into canvas onto a particular port. Note, a ~5 second sleep call should be made following this call to allow canvas to finish loading the icd.

Here is an example using python:

if not u2004.LoadIcdFromPath(r"C:\Absolute\Path\to\ICD\File\Canaan_GAMA.icd", "TX0", "Canaan Attitude Heading Computer"):
print("Failed to load icd into Canvas)
exit(1)
U2004.PortStart(U2004.A429Port.TX0)
print("Verify icd has loaded into Canvas")

◆ PortHs()

void PortHs ( A429Port  port,
byte  seq_num = 0 
)
inline

Sets an A429 port to High Speed (100kbs)

Here is the call graph for this function:

◆ PortLs()

void PortLs ( A429Port  port,
byte  seq_num = 0 
)
inline

Sets an A429 port to Low Speed (12.5kbs)

Here is the call graph for this function:

◆ PortStart()

void PortStart ( A429Port  port,
byte  seq_num = 0 
)
inline

Starts the Tx or Rx Port.

Here is the call graph for this function:

◆ PortStop()

void PortStop ( A429Port  port,
byte  seq_num = 0 
)
inline

tops the Tx or Rx Port

Here is the call graph for this function:

◆ PutIsUniqueSdi()

void PutIsUniqueSdi ( A429Port  port,
uint  word,
bool  is_unique_sdi,
byte  seq_num = 0 
)
inline

IsUniqueSdi is a property that can be attached to an ARINC 429 word where it tells the U2004 how to handle Source Designation Index (SDI) fields. The SDI is the 9th and 10th bits of an ARINC 429 word (the first 8 bits being the A429 label). For most application, the SDI is somewhat irrelevant because there usually is only one SDI field transmitted on a bus (out of four possible SDI with two-bits). The SDI being received is known by the receiving system by knowing which system the port is wired to. However, some systems, such as Distance Measurement Systems (DME) use the SDI field to differentiate between different channels. This means that the SDI needs to be differentiated by the processing equipment. If IsUniqueSdi configured for a label, then the SDI and Label fields (the first 10 bits) are processed together and all four versions of each label are chached and processed independently.

Here is the call graph for this function:

◆ PutParity()

void PutParity ( A429Port  port,
uint  word,
A429Parity  parity,
byte  seq_num = 0 
)
inline

Provided a A429 word, tells the U2004 what parity to accept on receiving ports, and what parity to put out on transmitting ports (Odd, Even, None).

Here is the call graph for this function:

◆ ReadDiscrete()

uint ReadDiscrete ( byte  seq_num = 0)
inline

Returns the state of discrete inputs to the U2004 (such as GND_DISC_IN_0, GND_DISC_IN_1, GND_DISC_IN_2) This function usually is used when UpdateStatus isn't called, because DiscreteInputs also provides the states inputs. Use ReadDiscrete(byte) if a blocking operation is needed to check the discrete input states.

Here is the call graph for this function:

◆ ReportStatus()

void ReportStatus ( byte  seq_num = 0)
inline

Requests the U2004 status; all ports, all discretes, and the operating mode.

Here is the call graph for this function:

◆ Reset()

void Reset ( byte  seq_num = 0)
inline

Full software reset of the U2004.

Here is the call graph for this function:

◆ ScheduleTxWord()

bool ScheduleTxWord ( A429Port  port,
uint  word,
ushort  time,
bool  is_froze,
byte  seq_num = 0 
)
inline

Puts a word into the transmit schedule at the specified time. Words in the schedule are transmittted autonomously and periodically by the U2004 without the need for any Host interaction. A transmit schedule is 2,777 words (for a High Speed bus) and 347 words (for a Low Speed bus), which represents all of the words that that can possibly be transmit in one second.

ScheduleTxWord is just like ScheduleTxWords (see the 's'). The later adds many words to the schedule, whereas ScheduleTxWord only puts one word in the schedule.

An important note is that a scheudled word is only transmitted once until UpdateTxWord is called. The host has an opportunity to update the word before that word gets put onto the wire more than one time. This ensure that the data is never stale. However, if is_froze is set to False, then the scheduled word will be tranmit constantly regardless if the host managed to update it in time before the next transmission.

Returns
Returns false if the word was not able to be scheduled, typically for reasons that there isn't room in the bus for the word count
Here is the call graph for this function:

◆ ScheduleTxWords()

void ScheduleTxWords ( A429Port  port,
uint  word,
ushort  time,
ushort  rate,
bool  is_froze,
byte  seq_num = 0 
)
inline

Puts a word into the transmit schedule at the specified time. Words in the schedule are transmittted autonomously and periodically by the U2004 without the need for any Host interaction. A transmit schedule is 2,777 words (for a High Speed bus) and 347 words (for a Low Speed bus), which represents all of the words that that can possibly be transmit in one second.

ScheduleTxWord is just like ScheduleTxWords (see the 's'). The later adds many words to the schedule, whereas ScheduleTxWord only puts one word in the schedule.

An important note is that a scheduled word is only transmitted once until UpdateTxWord is called. The host has an opportunity to update the word before that word gets put onto the wire more than one time. This ensure that the data is never stale. However, if is_froze is set to False, then the scheduled word will be tranmit constantly regardless if the host managed to update it in time before the next transmission.

Returns
Returns false if the word was not able to be scheduled, typically for reasons that there isn't room in the bus for the word count

Here is an example using python where multiple words are scheduled on the same port:

u2004.PortLs(U2004.A429Port.TX1)
u2004.PortStart(U2004.A429Port.TX1)
u2004.ScheduleTxWords(U2004.A429Port.TX1, 0x800000FF, 0 ,2, False)
u2004.ScheduleTxWords(U2004.A429Port.TX1, 0x800000AA, 0 ,2, False)
Here is the call graph for this function:

◆ SetDiscrete()

void SetDiscrete ( uint  mask,
byte  seq_num = 0 
)
inline

Writes to the U2004 discrete outputs (such as GND_DISC_OUT_0). See DiscreteOutputs for a listing and mapping of these discretes, which can be passed into the mask argument. This function specifically clears a ground/open discrete state.

Here is an example using python:

""" map a discrete to a variable """
GND_DISC_OUT_0 = 0x01
GND_DISC_OUT_7 = 0x80
""" set both discretes, GND_DISC_OUT_0 and GND_DISC_OUT_7 """
U2004_Hardware.SetDiscrete(GND_DISC_OUT_0 | GND_DISC_OUT_7)
Here is the call graph for this function:

◆ SetRxRate()

void SetRxRate ( A429Port  port,
uint  word,
ushort  rate,
byte  seq_num = 0 
)
inline

Sets the expected rate of an ARINC 429 word. This is used to determine if a received word is fresh or stale, meaning that it was received within twice the expected rate on average.

Here is the call graph for this function:

◆ SetWkn()

object SetWkn ( string  wkn,
double  value 
)
inline

Sets the value of a Well Known Name to the value provided for example SetWkn('TIME_TO_GO_BCD', 12.2) will set the value of 'TIME_TO_GO_BCD' to 12.2, to set a co-located non-WKN, use a collon to address that vlue. for example SetWkn('TIME_TO_GO_BCD:Sdi', 3) will set the Source Designation Index in the word that contains 'TIME_TO_GO_BCD' to 3. Note: Under the current implementation, this will always query the port that has had it's ICD set for the longest.

Here is an example using python:

if u2204.SetWkn("MAGNETIC_HEADING", 2) == None:
print("No matching definition found for 'MAGNETIC_HEADING'. Did you forget to load an ICD?")
else:
print("Check Canvas to manually verify value was set")

◆ SetWknString()

object SetWknString ( string  wkn,
string  value 
)
inline

Sets the value of a Well Known Name to the value provided for example SetWkn('TIME_TO_GO_BCD', 12.2) will set the value of 'TIME_TO_GO_BCD' to 12.2, to set a co-located non-WKN, use a collon to address that vlue. for example SetWkn('TIME_TO_GO_BCD:Sdi', 3) will set the Source Designation Index in the word that contains 'TIME_TO_GO_BCD' to 3.

◆ TcpCommunicate()

byte[] TcpCommunicate ( byte[]  frame,
bool  checksum = true 
)
inline

Sends and receives a frame without any additional discrimination through the TCP Connection. This function is typically only used by the Communicate function.

◆ TxWord() [1/2]

void TxWord ( A429Port  port,
List< uint >  words,
byte  seq_num = 0 
)
inline

Puts a list of words to be transmitted when space in schedule is available, but not that words that don;t fit into the frame are dropped if there is not room.

Here is the call graph for this function:

◆ TxWord() [2/2]

void TxWord ( A429Port  port,
uint  word,
byte  seq_num = 0 
)
inline

Puts a word to be transmitted when space in schedule is available.

Here is the call graph for this function:

◆ UnScheduleTxWord()

void UnScheduleTxWord ( A429Port  port,
uint  word,
byte  seq_num = 0 
)
inline

Removes all instances of a word, specifcally the first 8-bit label of a word, from the transmit schedule.

Here is the call graph for this function:

◆ UpdateTxWord() [1/2]

void UpdateTxWord ( A429Port  port,
List< uint >  words,
byte  seq_num = 0 
)
inline

Assuming that a A429 Word has been scheduled, and is actively being transmitted by the U2004, calling UpdateTxWord will update the word value that is in the schedule. It updates what is being transmitted. This also un-freezes words in the schedule if they were scheduled and expect fresh updates from the Host before transmit onto the wire. This call is more performant than the single uint call when scheduling many words.

Here is the call graph for this function:

◆ UpdateTxWord() [2/2]

void UpdateTxWord ( A429Port  port,
uint  word,
byte  seq_num = 0 
)
inline

Assuming that a A429 Word has been scheduled, and is actively being transmitted by the U2004, calling UpdateTxWord will update the word value that is in the schedule. It updates what is being transmitted. This also un-freezes words in the schedule if they were scheduled and expect fresh updates from the Host before transmit onto the wire.

◆ UsbConnect()

bool UsbConnect ( string  port)
inline

Opens a USB Connection to a U2004.

Returns
true if connected sucessfully
// returns true if successfully connected
if (U2004_Hardware.UsbConnect(u2004_i.ComPortName))
{
MessageBox.Show("connected!\n u2004 firmware version: " + U2004_Hardware.FirmwareVersion.ToString());
}

Field Documentation

◆ AsyncModeActive

bool AsyncModeActive = false

This is set True if the U2004 is in "Asyncronous Mode". See AsyncMode.

◆ ComFailed

bool ComFailed = false

True if there was a communication fault detected. Usually the device would need to be reconnector or re-instantiated, or there is fundamental fault. ComFailed is set when the communication frame received, wasn;t received in the correct format or length.

◆ CommPort

SerialPort CommPort

Serial Port for Communicating directly with the U2004 through the USB/COM port adapter. The U2004 is an FTDI port and can be communicated with through FTD2XX_NET.dll, but also through a generic COM port. Rates up to 921600bps have been tested. Use UsbConnect to open communication using the optimum settings.

◆ DeviceID

UInt32 DeviceID = 0

A unique serial number Id of the U2004, Updated on Initialize. This is hard-coded into the U2004. Canaan Avionics support software updates on this where required.

◆ DiscreteInputs

UInt32 DiscreteInputs = 0

These are the Discrete Input States (Gnd/Open) of the U2004, read after a UpdateStatus call.
This register can be read through a bool operation to get any one discrete, or read all together for all discretes.

The U2004 has three discrete inputs which are mapped as followed:

  • Pin 17 - GND_DISC_IN_0 - Mask 0x01
  • Pin 18 - GND_DISC_IN_1 - Mask 0x02
  • Pin 19 - GND_DISC_IN_2 - Mask 0x04
// get any A429Port, as all status requests will update DiscreteInputs
A429Port port = A429Ports[0]; */
// port.UpdateStatus(stat);

◆ DiscreteOutputs

UInt32 DiscreteOutputs = 0

These are the Discrete Output States (Gnd/Open) of the U2004, read after a UpdateStatus call.
This register can be read through a bool operation to get any one discrete, or read all together for all discretes. These are mosfet-driven discretes that are set through ClearDiscrete and SetDiscrete calls.

The U2004 has three discrete inputs which are mapped as followed:

  • Pin 28 - GND_DISC_OUT_0 - Mask 0x01
  • Pin 29 - GND_DISC_OUT_1 - Mask 0x02
  • Pin 30 - GND_DISC_OUT_2 - Mask 0x04
  • Pin 31 - GND_DISC_OUT_3 - Mask 0x08
  • Pin 32 - GND_DISC_OUT_4 - Mask 0x10
  • Pin 33 - GND_DISC_OUT_5 - Mask 0x20
  • Pin 34 - GND_DISC_OUT_6 - Mask 0x40
  • Pin 35 - GND_DISC_OUT_7 - Mask 0x80
// get any A429Port, as all status requests will update DiscreteOutputs
A429Port port = A429Ports[0]; */
// port.UpdateStatus(stat);

◆ FirmwareVersion

UInt32 FirmwareVersion = 0

Firmware Version of the U2004, Updated on Initialize. This is hard-coded into the U2004. Canaan Avionics support software updates on this where required.

◆ Index

byte Index = 0

The Index of this U2004 device. This Dll supports a single host and multiple U2004 interfaces. The Index can be used to direct which U2004 is communicated with.

◆ Mode

The active mode that this U2004 instance is communicating via.

◆ ReceivedFrame

byte [] ReceivedFrame = new byte[0]

The last USB communication frame received after a DataReceivedHandler call-back event.

◆ Status

List<PortStatus> Status = new List<PortStatus>()

A list of all of the PortStatus. This whole list is updated each time UpdateStatus is called. This list may be iterated or searched with lynq to find the port status for an particular port.

◆ TimeOut

int TimeOut = 4000

The amount of time (ms) for Communicate to wait for a frame from the U2004. If there is no response in that time, then the frame is received as null.