초기 커밋.
This commit is contained in:
203
LFP_Manager_PRM/DataStructure/csSbCanLibConstData.cs
Normal file
203
LFP_Manager_PRM/DataStructure/csSbCanLibConstData.cs
Normal file
@@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LFP_Manager.DataStructure
|
||||
{
|
||||
/*************************************
|
||||
Serial Info Struct
|
||||
**************************************/
|
||||
[Serializable]
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct SerialConfigInfo
|
||||
{
|
||||
public UInt32 Baudrate;
|
||||
public byte data;
|
||||
public byte parity;
|
||||
public byte stop;
|
||||
public byte flow;
|
||||
}
|
||||
|
||||
enum DataBits
|
||||
{
|
||||
Data8 = 8,
|
||||
};
|
||||
|
||||
enum Parity
|
||||
{
|
||||
NoParity = 0,
|
||||
EvenParity = 2,
|
||||
OddParity = 3,
|
||||
SpaceParity = 4,
|
||||
MarkParity = 5
|
||||
};
|
||||
|
||||
enum StopBits
|
||||
{
|
||||
OneStop = 1,
|
||||
TwoStop = 2
|
||||
};
|
||||
|
||||
enum FlowControl
|
||||
{
|
||||
NoFlowControl,
|
||||
HardwareControl
|
||||
};
|
||||
|
||||
enum SerialBaudRate
|
||||
{
|
||||
SerialBaud300 = 300,
|
||||
SerialBaud600 = 600,
|
||||
SerialBaud1200 = 1200,
|
||||
SerialBaud2400 = 2400,
|
||||
SerialBaud3600 = 3600,
|
||||
SerialBaud4800 = 4800,
|
||||
SerialBaud7200 = 7200,
|
||||
SerialBaud9600 = 9600,
|
||||
SerialBaud19200 = 19200,
|
||||
SerialBaud38400 = 38400,
|
||||
SerialBaud57600 = 57600,
|
||||
SerialBaud115200 = 115200,
|
||||
SerialBaud230400 = 230400,
|
||||
SerialBaud460800 = 460800,
|
||||
SerialBaud921600 = 921600,
|
||||
SerialUnknownBaud = -1
|
||||
};
|
||||
|
||||
enum CANBaudRate
|
||||
{
|
||||
CANBaud20 = 20,
|
||||
CANBaud50 = 50,
|
||||
CANBaud100 = 100,
|
||||
CANBaud125 = 125,
|
||||
CANBaud200 = 200,
|
||||
CANBaud250 = 250,
|
||||
CANBaud300 = 300,
|
||||
CANBaud500 = 500,
|
||||
CANBaud800 = 800,
|
||||
CANBaud1000 = 1000,
|
||||
CANUnknownBaud = -1
|
||||
};
|
||||
|
||||
//public class csSbCanLibConstData
|
||||
//{
|
||||
/*************************************
|
||||
define
|
||||
**************************************/
|
||||
//public bool ISDAR(byte x)
|
||||
// {
|
||||
// return (x & 0x01) != 0x00;
|
||||
// }
|
||||
|
||||
//public bool ISABOR(byte x)
|
||||
// {
|
||||
// return (x & 0x02) != 0x00;
|
||||
//}
|
||||
|
||||
//public void SETDAR(ref byte x)
|
||||
// {
|
||||
// x |= 0x01;
|
||||
// }
|
||||
//public void SETABOR(ref byte x)
|
||||
//{
|
||||
// x |= 0x02;
|
||||
//}
|
||||
|
||||
//public const byte CR = 0x0D;
|
||||
|
||||
////Error Code
|
||||
//public const byte Invalid_Arg = 0x01;
|
||||
//public const byte No_Error = 0x00;
|
||||
|
||||
enum CAN_StructFormat
|
||||
{
|
||||
TX_STD_DATA = 0x14,
|
||||
TX_STD_REMOTE = 0x15,
|
||||
TX_EXT_DATA = 0x16,
|
||||
TX_EXT_REMOTE = 0x17,
|
||||
RX_STD_DATA = 0x04,
|
||||
RX_STD_REMOTE = 0x05,
|
||||
RX_EXT_DATA = 0x06,
|
||||
RX_EXT_REMOTE = 0x07
|
||||
};
|
||||
|
||||
/*************************************
|
||||
CAN Serial Struct
|
||||
**************************************/
|
||||
[Serializable]
|
||||
[StructLayout(LayoutKind.Sequential, Pack=1)]
|
||||
public struct CAN_Struct
|
||||
{
|
||||
public byte Format;
|
||||
public UInt32 ID;
|
||||
public byte DLC;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public byte[] DATA;
|
||||
}
|
||||
|
||||
/*************************************
|
||||
CAN Info Struct
|
||||
**************************************/
|
||||
[Serializable]
|
||||
[StructLayout(LayoutKind.Sequential, Pack=1)]
|
||||
public struct CANConfigInfo
|
||||
{
|
||||
public UInt32 Baudrate;
|
||||
public UInt32 ID;
|
||||
public UInt32 Mask;
|
||||
public byte Spec;
|
||||
public bool DAR;
|
||||
public bool ABOR;
|
||||
}
|
||||
enum CANSpec
|
||||
{
|
||||
CAN_A = 3, //Max Standard CAN ID Length for ascii (0~7FF)
|
||||
CAN_B = 8 //Max Extended CAN ID Length for ascii (0~1FFFFFFF)
|
||||
};
|
||||
|
||||
/*************************************
|
||||
Option Info Struct
|
||||
**************************************/
|
||||
[Serializable]
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct OptionInfo
|
||||
{
|
||||
public byte mode;
|
||||
public byte delay;
|
||||
public byte STD_D_Command_Header;
|
||||
public byte STD_R_Command_Header;
|
||||
public byte EXT_D_Command_Header;
|
||||
public byte EXT_R_Command_Header;
|
||||
}
|
||||
public static class CAN_SerialCommandHeader
|
||||
{
|
||||
public static readonly char STD_DATA = 't';
|
||||
public static readonly char STD_REMOTE = 'T';
|
||||
public static readonly char EXT_DATA = 'e';
|
||||
public static readonly char EXT_REMOTE = 'E';
|
||||
}; //CS-CAN Default Serial Command Header
|
||||
|
||||
/*************************************
|
||||
CAN Error Info Struct
|
||||
**************************************/
|
||||
[Serializable]
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct CANErorrInfo
|
||||
{
|
||||
public byte TEC; // Transmit Error Count
|
||||
public byte REC; // Receive Error Count
|
||||
public byte LEC; // Last Error Count
|
||||
public UInt32 StuffCount; // Stuff Error Count
|
||||
public UInt32 FormCount; // Form Error Count
|
||||
public UInt32 AckECount; // Ack Error Count
|
||||
public UInt32 BitCount; // Bit Error Count
|
||||
public UInt32 CRCCount; // CRC Error Count
|
||||
|
||||
public byte errorInfo; // Erroe Status
|
||||
}
|
||||
//}
|
||||
}
|
||||
Reference in New Issue
Block a user