Blame | Last modification | View Log | Download
/*name testslav.h*//* Copyright (C) Modicon, Inc. 1989, All Rights Reserved. *//*definitions*/#define IDLE 0 /*markers for processing DXs/SLAVEs*/#define NEWRQ 1#define REQDN 2#define DXQED 0 /*return status for DXs/SLAVEs*/#define DXERROR 1#define DXACTIVE 2#define DXDONE 4#define DXCRAZY 7#define DXR5 -1 /*DX paramter index */#define DXR4 -2#define DXR3 -3#define DXR2 -4#define DXR1 -5#define DXR0 -6#define DXFNCODE -7#define DXSTATUS -8#define EXECMCODE 1 /* minicode execution at eos */#define READ 2 /*984 registers read/write codes*/#define WRITE 4#define ABS_MEM 8#define MAXDXTASKS 8 /*maximum tasks*/#define MAXSLTASKS 8#define PAGEMASK 0x8000#define PAGEF 0xF#define PAGE0 0#define PAT55AA 0x55AA /* patterns for error checking */#define PATAA55 0xAA55#define PAT33CC 0x33CC#define PATCC33 0xCC33#define PAT00FF 0x00FF#define PATFF00 0xFF00#define SLAVEINITQID 0x90#define SLAVEDONEQID 0x91#define QSIZE 10#define FORANYERROR 0xFF00 /* any error pattern */#define NODMACC 0xF100 /* common 984 interface errors */#define BADHOOK 0xF200#define TOKENNOTGONE 0xF300#define NOBUSGRANT 0xF400#define TOOLONG 0xF500#define NOULTOKEN 0x0100 /* user logic errors */#define BADLENG 0x0200#define NOPUPTOKEN 0x1100 /* power up errors */#define TEST0FAIL 0x1200#define ICBRDFAIL 0x1300#define TEST1FAIL 0x1400#define DONEFAIL 0x1500#define NODIMTOKEN 0x2100 /* exit DIM errors */#define CFGRDFAIL 0x2200#define NOEOSTOKEN 0x3100 /* end of scan errors */#define BADSLREQ 0x3200#define PCINDIM 0x3300#define PATCHKERR 0x4100#define OSCALLERR 0x5100#define MISCERRS 0x6100#define CRX1 1 /* com1 receive device */#define CTX1 2 /* com1 transmit device */#define CRX2 3 /* com2 receive device */#define CTX2 4 /* com2 transmit device */#define CRX3 5 /* com3 receive device */#define CTX3 6 /* com3 transmit device */#define CRX4 7 /* com4 receive device */#define CTX4 8 /* com3 transmit device */#define IMMDXTASK 1#define SLINITTASK 2#define SLDONETASK 3#define DEFDXTASK1 4#define DEFDXTASK2 5#define DEFDXTASK3 6#define DEFDXTASK4 7#define DEFDXTASK5 8#define DEFDXTASK6 9#define DEFDXTASK7 10#define DEFDXTASK8 11#define DMALIB 12/* global structure for communication between interrupt handler and DX processing routine */struct dxparamst{unsigned status; /* on return bit 2-0 = power out top-bottom */unsigned dxfnno; /* on entry = function no */unsigned r0; /* bit 15=1 if r1 is a constant */unsigned r1; /* on entry = top argument of DX */unsigned r2; /* bit 15=1 if middle in power on */unsigned r3; /* on entry = 984 adrs of table */unsigned r4; /* bit 15=1 if lower power on */unsigned r5; /* size of table (1-255) */unsigned table[255]; /* local copy of table of registers */};/*This structure "dma_sys_dat_tblt" moved to CTABLE.H, andreferred to as "dma_system_data_table", contents remain unchanged.*/struct dma_sys_dat_tblt{unsigned sys_sw_rev_no;unsigned imm_dx_sys_no;unsigned imm_dx_usr_no;unsigned def_dx_sys_no;unsigned def_dx_usr_no;unsigned future_use;unsigned task_no;unsigned error_code;unsigned long def_dx_buf_list;unsigned long sl_req_buf_list;unsigned long cfg_table;unsigned long dma_mbox;};struct def_dx_buft /* DX message template */{unsigned pat_55AA; /* pattern to recognize the dx buffer */char *dx_mbox; /* mail box*/unsigned dx_buf_state; /* sephamore *//* REQDN-> IDLE-> NEWRQ by interrupt handler*//* NEWRQ-> REQDN by deferred_dx dispatcher*/unsigned dx_status;unsigned dx_dxfnno;unsigned dx_r0;unsigned dx_r1;unsigned dx_r2;unsigned dx_r3;unsigned dx_r4;unsigned dx_r5;unsigned dx_table[255];unsigned pat_AA55; /* pattern to recognize the dx buffer */};struct sl_buft /* SLAVE message template */{unsigned pat_33CC; /* pattern to recognize the slave buffer */unsigned long sl_mbox; /* mail box at which it gets reply */unsigned sl_buf_state;unsigned sl_status;unsigned req_type;unsigned offset_4xxxx;unsigned pc_page;unsigned pc_addr;unsigned nwords;unsigned *words_adrs;unsigned pat_CC33; /* pattern to recognize the slave buffer */};struct cfgt{unsigned os0x_len; /* 0xxxx output states */unsigned os0x_adr;unsigned os0x_pag;unsigned is1x_len; /* 1xxxx input states */unsigned is1x_adr;unsigned is1x_pag;unsigned ir3x_len; /* 3xxxx input registers */unsigned ir3x_adr;unsigned ir3x_pag;unsigned or4x_len; /* 4xxxx output registers */unsigned or4x_adr;unsigned or4x_pag;unsigned up4x_len; /* 4xxxx up-counter power histories */unsigned up4x_adr;unsigned up4x_pag;unsigned dn4x_len; /* 4xxxx down-counter power histories */unsigned dn4x_adr;unsigned dn4x_pag;unsigned hs0x_len; /* 0xxxx histories */unsigned hs0x_adr;unsigned hs0x_pag;unsigned hs1x_len; /* 1xxxx histories */unsigned hs1x_adr;unsigned hs1x_pag;unsigned ds0x_len; /* 0xxxx disables */unsigned ds0x_adr;unsigned ds0x_pag;unsigned ds1x_len; /* 1xxxx disables */unsigned ds1x_adr;unsigned ds1x_pag;unsigned ul_len; /* user logic */unsigned ul_adr;unsigned ul_pag;unsigned asc_len; /* ascii */unsigned asc_adr;unsigned asc_pag;unsigned wdt; /* watch dog timer */};extern struct dxparamst _DMA_dxparams;/** function/function # equates:* f_nosuch 500* no deferred function 500 is allowed, so as not to get confused with* immediate function 500* f_dbwrite 501 write 986 database from 984* f_dbread 502 read 986 database from 984** following are modbus master functions:* mod_1 503* mod_2 504* mod_3 505* mod_4 506* mod_5 507* mod_6 508* mod_7 509* mod_8 510* mod_15 511* mod_16 512* mod_17 513** f_slave 514 modbus slave function** f_dgets 515 issue dgets(void) on com line* f_dputs 516 issue dputs(void) on com line** Note: f_dgets_echo (517) which was in prelim release 1 was deleted for rel2** f_sprintf 518 character string generation* f_sscanf 519 character string interpretation*//*************************************************************************/#define SUCCESS 0 /* last operation successful */#define FAILURE -1 /* last operation not successful, not retryable */#define TIMEOUT 100 /* Timeout 2 seconds for Ascii Modbus */#define MODMODE 0 /* Modbus 0=ASCII 1=RTU *//* DEBUGPORT only for choosing which port to use for debugging messages */#define DEBUGPORT 4 /* Port to use for Debugging displays *//*** to enable debugging statements to be sent out DEBUGPORT make sure the** #define DEBUG statement below is NOT commented out.** (#ifdef DEBUG....(output debugging statements out DEBUGPORT))*//* #define DEBUG *//*************************************************************************//* For testing in MSDOS environment, leave the #define in *//* For use in the C986 co-processor environment, comment the #define out *//* #define MSDOS_TESTING 1 *//*************************************************************************//* CALL block table of registers: register offsets */#define PORT 0 /* Modbus master port to use (C986) (1-4) */#define SLAVE 1 /* USER: Slave # to address */#define ADDRESS 2 /* USER: Slave data address */#define QUANTITY 3 /* USER: quantity of regs in/out*/#define MODE 4 /* USER: 0 = ASCII 1 = RTU mode(relaxed timing only)*/#define M_STATUS 5 /* Modbus master status word */#define DATA1 6 /* First data block word *//* (all other data regs follow) *//* error code numbers for table [M_STATUS] *//* Group 0: USER reg errors */#define BAD_SLAVE 1 /* slave # not correct */#define BAD_ADDRESS 2 /* slave data addr not correct */#define BAD_QUANTITY 3 /* data quantity not correct */#define BAD_SIZING 4 /* quantity and DXSIZE conflict */#define BAD_MODE 5 /* the mode was not recognized */#define NOT_SUPPORTED 9 /* modbus code is not supported **** in this version of "master.c"*//* Group 1: Read errors */#define RD_TIMEOUT 0x101 /* slave response time out */#define RD_NO_LF 0x102 /* slave response incomplete */#define RD_NO_PREFIX 0x103 /* ':' was not first char rcv'd **** (ASCII mode only) */#define RD_EVEN_NCHAR 0x104 /* # chars rcv'd was even (ASCII**** mode error only) */#define RD_BAD_CHAR 0x105 /* non hex character read (ASCII**** mode error only) */#define RD_BAD_LRC 0x106 /* response bad LRC (ASCII mode)*/#define RD_BAD_CRC 0x107 /* response bad CRC (RTU mode) */#define RD_WRONG_SLAVE 0x108 /* wrong slave replied to cmd */#define RD_WRONG_FUNC 0x109 /* slave responded to wrong **** function code */#define RD_OVERFLOW 0x10A /* buffer overflow occured */#define RD_AD_LEN 0x10B /* reply len <> implied len *//* Group 2: exception responses */#define RD_EXCEPTION 0x200 /* last 2 digits contain ex code*//* 0x201 illegal function code *//* 0x202 illegal data address *//* 0x203 illegal data value *//* 0x204 failure in associated device */#define ACK 0x5 /* acknowledge(0x205) */#define BUSY 0x6 /* busy, rejected message(0x206) */#define NAK 0x7 /* NAK - negative acknowledgement(0x207) */#define ASCII 0x0 /* Ascii Modbus */#define RTU 0x1 /* RTU Modbus *//************************** end of testslav.h *******************/