Ejemplo n.º 1
0
        public TPCANStatus WriteFrame(UInt32 Id, int DataLength, byte[] Data)
        {
            TPCANMsg CANMsg;

            // Create a TPCANMsg message structure
            CANMsg = new TPCANMsg();

            // Configure the Message Type.
            CANMsg.MSGTYPE = TPCANMessageType.PCAN_MESSAGE_STANDARD;
            // Message contents (ID, Length of the Data, Data)
            CANMsg.ID   = Id;
            CANMsg.LEN  = (byte)DataLength;
            CANMsg.DATA = Data;

            // The message is sent to the configured hardware
            LastOperationStatus = PCANBasic.Write(PeakCANHandle, ref CANMsg);
            if (LastOperationStatus != TPCANStatus.PCAN_ERROR_OK)
            {
                LastOperationErrorMessage();
            }
            return(LastOperationStatus);
        }
Ejemplo n.º 2
0
 public static extern TPCANStatus Write(
     [MarshalAs(UnmanagedType.U2)]
     TPCANHandle Channel,
     ref TPCANMsg MessageBuffer);
Ejemplo n.º 3
0
 /// <summary>
 /// Reads a CAN message from the receive queue of a PCAN Channel
 /// </summary>
 /// <param name="Channel">The handle of a PCAN Channel</param>
 /// <param name="MessageBuffer">A TPCANMsg structure buffer to store the CAN message</param>
 /// <returns>A TPCANStatus error code</returns>
 public static TPCANStatus Read(
     TPCANHandle Channel,
     out TPCANMsg MessageBuffer)
 {
     return(Read(Channel, out MessageBuffer, IntPtr.Zero));
 }
Ejemplo n.º 4
0
 private static extern TPCANStatus Read(
     [MarshalAs(UnmanagedType.U2)]
     TPCANHandle Channel,
     out TPCANMsg MessageBuffer,
     IntPtr bufferPointer);
Ejemplo n.º 5
0
 public static extern TPCANStatus Read(
     [MarshalAs(UnmanagedType.U2)]
     TPCANHandle Channel,
     out TPCANMsg MessageBuffer,
     out TPCANTimestamp TimestampBuffer);