| | |
| | | extern unsigned char PacketBuf1[128];
|
| | | extern unsigned char PacketBuf2[128];
|
| | |
|
| | | typedef struct tagKBusRunStat
|
| | | {
|
| | | unsigned char bMaster;
|
| | | unsigned char nStationID;
|
| | | unsigned char nChildren;
|
| | | unsigned char nCurPollId;
|
| | | unsigned char nSeq;
|
| | |
|
| | | unsigned char bMasterRecved;
|
| | | unsigned char bMasterRecvOK;
|
| | | unsigned char bSlaveRecved;
|
| | | unsigned int nSendTimeuS;
|
| | |
|
| | | }stKBusRunStat , * pstKBusRunStat;
|
| | |
|
| | | extern unsigned char BufferIn[16];
|
| | | extern unsigned char BufferOut[16];
|
| | | extern unsigned char nAddr;
|
| | | extern unsigned char nStationID;
|
| | | extern unsigned char nChilds;
|
| | | extern int ChildStat[16];
|
| | | extern unsigned char nCurPollId;
|
| | | extern unsigned char nSeq;
|
| | |
|
| | | extern volatile unsigned char MasterRecved;
|
| | | extern volatile unsigned char MasterRecvOK;
|
| | | extern volatile unsigned char SlaveRecved;
|
| | | extern unsigned int SendTimeuS;
|
| | | extern volatile int RecvTimeuS;
|
| | | extern int DelayuS;
|
| | | extern int MaxDelayuS;
|
| | | extern volatile unsigned char KBusMasterRecved;
|
| | | extern volatile unsigned char KBusMasterRecvOK;
|
| | | extern volatile unsigned char KBusSlaveRecved;
|
| | | extern unsigned int KBusSendTimeuS;
|
| | | extern volatile int KBusRecvTimeuS;
|
| | | extern int KBusDelayuS;
|
| | | extern int KBusMaxDelayuS;
|
| | |
|
| | | extern volatile unsigned int nSlaveTick;
|
| | |
|
| | |
|
| | |
|
| | | typedef struct tagVerInfo
|
| | | {
|
| | |
| | | unsigned char OutPutCount;
|
| | | unsigned char InDWCount;
|
| | | unsigned char OutDWCount;
|
| | | |
| | | unsigned char Online;
|
| | | unsigned char bOnline;
|
| | | };
|
| | |
|
| | | #pragma anon_unions
|
| | |
| | | };
|
| | | } stChnStat;
|
| | |
|
| | | extern stChnStat ChnStats[8];
|
| | | extern stChnStat KBusChnStats[8];
|
| | |
|
| | | typedef struct tagSlaveStat
|
| | | {
|
| | |
| | | evClosed = 4,
|
| | | };
|
| | |
|
| | | typedef struct tagPacket
|
| | | typedef struct tagKBPacket
|
| | | {
|
| | | unsigned char Sign; //��ʼ��� |
| | | unsigned char DstHost; //Ŀ���ַ
|
| | | unsigned char SrcAddr; //Դ��ַ
|
| | | unsigned char nCMD; //����
|
| | | unsigned char nSEQ; //���к�
|
| | | unsigned char PacketLen; //�����غɳ��� ������ͷ��5���ֽڣ�������β��BCC��
|
| | | unsigned char data[1]; //�����غ�,��ĩβ��BCC�����ݳ���Ϊ0ʱ��ʵ��Ҳ��һ�����ݡ�
|
| | | }stPacket,* pPacket; |
| | | unsigned char Sign; //起始标记 |
| | | unsigned char DstHost; //目标地址
|
| | | unsigned char SrcAddr; //源地址
|
| | | unsigned char nCMD; //命令
|
| | | unsigned char nSEQ; //序列号
|
| | | unsigned char PacketLen; //数据载荷长度 不包括头部5个字节,不包括尾部BCC。
|
| | | unsigned char data[1]; //数据载荷,最末尾是BCC,数据长度为0时,实际也有一个数据。
|
| | | }stKBPacket,* pKBPacket; |
| | |
|
| | | enum eResult
|
| | | {
|
| | |
| | |
|
| | | } ;
|
| | |
|
| | | unsigned char BCC(void * pData, int nSize);
|
| | | unsigned char KBusBCC(void * pData, int nSize);
|
| | | //
|
| | | /* Make a Packet and return Packet Length */
|
| | | int MakePacket(pPacket p1,uchar Src, uchar Dst, uchar nType, uchar nSEQ, uchar DataLen, void *pData );
|
| | | int KBusMakePacket(pKBPacket p1,uchar Src, uchar Dst, uchar nType, uchar nSEQ, uchar DataLen, void *pData );
|
| | |
|
| | | /* */
|
| | | int CheckPacket(int nChn, pPacket p1, int len1);
|
| | | int KBusCheckPacket(int nChn, pKBPacket p1, int len1);
|
| | |
|
| | | /* */
|
| | | int ParsePacket(int nChn, pPacket p1, int Len1);
|
| | | int KBusParsePacket(int nChn, pKBPacket p1, int Len1);
|
| | | typedef struct tagMachineConfig
|
| | | {
|
| | | int bKBusMaster;
|
| | | int nAddr;
|
| | | }stMachineConfig;
|
| | |
|
| | | /*
|
| | | int InitMachine(stMachineConfig * pConfig);
|
| | |
|
| | | int SetConfig(void );
|
| | |
| | | int WriteData(void);
|
| | |
|
| | | int GetStat(void);
|
| | |
|
| | | */
|
| | | int KBusRepeaterFunc(int nChn);
|
| | | int KBusMasterFunc(int nChn);
|
| | | int KBusSlaveFunc(int nChn);
|