www.pudn.com > PROFIBUS_DP_protocol_source.ZIP > vardef.h, change:2004-03-17,size:35806b


//----------------------------------------------------------------------------- 
// $Id: vardef.h,v 1.0.0                                            2004/01/13 
//----------------------------------------------------------------------------- 
// 
//      ProfiM - PROFIBUS MASTER DRIVER FOR WINDOWS NT/2000 
// 
// Author:   
//      Pavel Trnka, CTU FEE 
//      trnkap@seznam.cz 
// With help and advices from: 
//      Ing. Petr Smolik, CTU FEE 
//      Ing. Pavel Pisa, CTU FEE 
//      Ing. Pavel Burget, CTU FEE 
//----------------------------------------------------------------------------- 
// 
// Popis: 
// ------ 
// Definice dulezitych datovych typu, standartnich struktur FDL a konstant. 
// Dulezitou casti jsou ihned v uvodu definice falesnych maker urciji podminky 
// pro preklad. 
// 
//----------------------------------------------------------------------------- 
//----------------------------------------------------------------------------- 
 
 
 
#ifndef _VARDEF_H 
#define _VARDEF_H 
 
 
#include "NTDDK.H"   
 
// SS-FORMAT-OFF 
 
//***************************************************************************** 
//** 
//**                        PODMINKY PRO PREKLAD 
//** 
//** Doporucene podminky pro preklad pro Windows 2000, definovat falesna makra: 
//** PnP, PISA_IO, USE_RX_FIFO, AUTOMATIC_RX, USE_WATCHDOG 
//** 
//** Doporucene podminky pro preklad pro Windows NT, definovat falesna makra: 
//** PISA_IO, USE_WATCHDOG 
//** 
//***************************************************************************** 
 
// 
// prelozi ovladac s PnP podporou pro pouziti pod Windows 2000 a Windows XP 
// 
//#define PnP            
 
// 
// pro odstraneni cekani ve smycce se bude pouzivat preruseni od modemu (pouze 
// pro standratni seriovy port - u 16PCI954 neni potreba - u te se nikde ne- 
// ceka) 
// 
#define PISA_IO          
 
// 
// Povoli pouzivani FIFO pameti pro prijem dat (pouze pro 16PCI954). 
// FIFO pro vysilani dat je pouzivana vzdy (pouze pro 16PCI954). 
// 
//#define USE_RX_FIFO 
 
// 
// Pro obvod 16PCI954 nastavi automaticke prepinani na prijem po vyslani 
// celeho ramce. Zaroven je pro prijem ramcu vyuzivano cele prijimaci 
// FIFO. Jedinou nevyhodou je, ze po prijeti celeho ramce je preruseni 
// generovano se spozdenim 4 znaku - tj. 44Tbitu. Coz by ovsem pro dostatecne 
// dlouhe reakcni casy site (maxTSDR) nemelo vadit. Na druhou stranu nam to 
// umozni dosahovat vysokych prenosovych rychlosti.  
// 
//#define AUTOMATIC_RX 
 
// 
// Povoli pouziti WatchDogu - ten s periodou 1s kontroluje aktivitu 
// driveru a v pripade zatuhnuti jej restartuje. 
// 
#define USE_WATCHDOG 
 
// 
// Mnozstvi vypisovanych debug informaci (pomoci fce DbgPrint): 
//  1 - vypisuje vse 
//  2 - vypisuje informace o provozu na sbernici (typy vysilanych/prijimanych ramcu apod.) 
//  3 - vypisuje pouze zakladni informace a kriticke chyby 
//  4 - vypis je zcela vypnut 
// 
#define ERROR_LEVEL   3    
 
// 
// 1 - ovladac vypisuje ladici informace z PnP casti 
// 0 - bez vypisu 
// 
#define PnP_DBG       0    
 
 
//***************************************************************************** 
//** 
//**  Driver controll structure 
//** 
//*****************************************************************************                
 
#define PROFIM_MAGIC 0x13061980 
 
 
//***************************************************************************** 
//** 
//**  Identifikace ramcu (Start/End delimiters) 
//** 
//***************************************************************************** 
 
#define DelimiterSD1     0x10 
#define DelimiterSD2     0x68 
#define DelimiterSD3     0xA2 
#define DelimiterSD4     0xDC 
#define DelimiterSC      0xE5 
#define DelimiterED      0x16 
 
 
 
//***************************************************************************** 
//** 
//**  Delky bufferu 
//** 
//***************************************************************************** 
 
#define RQ_BUFFER_SIZE    20 // Request buffer size 
#define RS_BUFFER_SIZE    20 // Result buffer size 
#define IRP_BUFFER_SIZE  100 // Irp buffer size 
#define INBUF_SIZE      1024 // Velikost vstupniho bufferu pro data z vnejsku 
#define DEF_BUFFER_SIZE 2000 // Velikost bufferu pro vysilani 
 
 
 
//***************************************************************************** 
//** 
//**  Default parametry mastera 
//** 
//***************************************************************************** 
 
#define DEF_BAUD_RATE           9600 
#define HSA_default             15       // Highest Station Address 
#define TS_default              7        // This Station address 
#define G_default               2        // Gap update factor 
//#define Baud_rate_default     kbaud_9_6 
#define Baud_rate_num_default   9600     
#define medium_red_default      no_redundancy 
#define retry_ctr_default       1 
#define default_sap_default     10 
#define TSL_default             300 //60 // SLOT time 
#define TQUI_default            0        // Transmitter fall time /  
                                         // repeater changeover time 
#define TSET_default            0        // Setup time 
#define min_TSDR_default        12       // Minimum Station Delay Time (Response) 
#define max_TSDR_default        55       // Maximum Station Delay Time (Response) 
#define TTR_default             2000     // Time To Reach 
#define in_ring_desired_default flc_true 
#define physical_layer_default  rs485 
 
#define Tto                     4000     // Time Out 
 
 
// 
// so far unused 
// 
 
//#define tTD                                 1 
//#define Timer_set                           65000 
 
//#define time_out_threshold_default          0xffff 
#define not_syn_threshold_default           0xffff 
#define uart_error_threshold_default        0xffff 
#define out_of_ring_threshold_default       0xffff 
#define sdn_not_indicated_threshold_default 0xffff 
#define duplicate_address_threshold_default 0xffff 
#define hardware_error_threshold_default    0xffff 
#define mac_error_threshold_default         0xffff 
 
 
 
//***************************************************************************** 
//** 
//**  Definice typu znaku zapisovanych do vystupniho bufferu 
//** 
//***************************************************************************** 
 
#define DATA_CHAR         0 
#define TIMING_CHAR       1 
#define SYN_CHAR          2 
 
//Hodnoty posilane na interface pokud prijdou na radu casovaci znaky. 
//Interface je prepnuty na prijem, takze znaky se na sbernici nedostanou, 
//ale jejich hodnota je dulezita pro generovani preruseni od stavu modemu. 
//V interfacu musi byt propojen TxD se vstupem DSR. Vyslanim znaku 0x00 
//potom prijdou dve preruseni od stavu modemu. 
//Neni-li v interfacu toto pro propojeni, je nutno ovladac prelozit bez 
//definovaneho falesneho makra PISA_IO 
#define SYN_BYTE          0x00 
#define TIMING_BYTE       0x00 
 
 
 
//***************************************************************************** 
//** 
//**  Retezce pro naplneni identifikacni struktuty Ident 
//** 
//***************************************************************************** 
 
#define Vendor_name       "CTU-FEE" 
#define Controller_type   "ProfiM - Windows Profibus DP Master Driver" 
#define HW_release        "1.0" 
#define SW_release        "0.015" 
 
// SS-FORMAT-ON 
 
 
//***************************************************************************** 
//** 
//**  Makra pro vypis stavovych a chybovych informaci 
//** 
//***************************************************************************** 
 
// pozor neumoznuje vypisy s parametry jako napr. DbgPrint("abc %d",x); 
#define RS_DbgPrint(a)  DbgPrint(a)              
 
//umoznuji vypisy s parametry 
#define PB_DbgPrintL1 if (ERROR_LEVEL==1) DbgPrint 
#define PB_DbgPrintL2 if (ERROR_LEVEL<=2) DbgPrint 
#define PB_DbgPrintL3 if (ERROR_LEVEL<=3) DbgPrint 
 
 
 
 
//***************************************************************************** 
//***************************************************************************** 
 
 
// FC znaky 
#define FCMasterNotReady        0x10 
#define FCMasterReady           0x20 
#define FCMasterInLogicalRing   0x30 
 
 
#define SAPDefault              0xff     
#define SAPNIL                  0x80    // dost divny je definovat rozsah hodnot 0-63 a Nil (128 dle strany 639) jinde je vsak definova jako 0xFF 
#define SAPAll                  0xff    // umoznuje pristup do LSAPu ze vsech RSAPu 
#define AccessAll               0x7f    // umoznuje pristup do LSAPu ze vsech stanic 
 
 
typedef UCHAR   UBYTE; 
typedef CHAR    BYTE; 
typedef USHORT  UWORD; 
typedef ULONG   UDWORD; 
 
typedef enum 
{ 
  Offline               = 0, 
  Listen_Token, 
  Active_Idle, 
  Claim_Token, 
  Use_Token, 
  Await_Data_Resp, 
  Check_Access_Time, 
  Pass_Token, 
  Check_Token_Pass, 
  Await_Status_Resp 
} TMasterState; 
 
typedef enum 
{ 
  Slave                     = 0, 
  Master_not_ready          = 1, 
  Master_ready              = 2, 
  Master_in_logical_ring    = 3 
} TStationStatus; 
 
 
 
typedef enum 
{ 
  TO_StartNow         = 0, 
  TO_StartTxEmpty 
} TTimeOutStartCondition; 
 
typedef enum 
{ 
  TO_Stopped            = 0, 
  TO_Running, 
  TO_WaittingTxEmpty 
} TTimeOutState; 
 
 
typedef enum 
{ 
  RLL_Stopped           = 0, 
  RLL_TestNext, 
  RLL_WaitNextCycle 
} T_RLL_Status; 
 
 
 
typedef enum 
{ 
  ACK_OK                                                                        = 0x00, 
  /* ACK. positive                                                        */ 
  ACK_UE                                                                        = 0x01, 
  /* ACK. negative:   remote-USER/FDL interface error                     */ 
  ACK_RR                                                                        = 0x02, 
  /* ACK. negative:   no remote resource available                        */ 
  ACK_RS                                                                        = 0x03, 
  /* ACK. negative:   service or rem_add at remote-lsap not activated     */ 
  ACK_DL                                                                        = 0x08, 
  /* response-data (l_sdu) low available                                  */ 
  ACK_NR                                                                        = 0x09, 
  /* ACK. negative:   no response-data at remote-FDL available            */ 
  ACK_DH                                                                        = 0x0a, 
  /* response-data (l_sdu) high available                                 */ 
  ACK_RDL                                                                       = 0x0c, 
  /* response-data (l_sdu) low available, but negative-ACK for send-data  */ 
  ACK_RDH                                                                       = 0x0d, 
  /* response-data (l_sdu) high available, but negative-ACK for send-data */ 
 
  ACK_LS                                                                        = 0x10, 
  /* service not activated at local sap                                   */ 
  ACK_NA                                                                        = 0x11, 
  /* no reaction (ACK/RES) from remote-station                            */ 
  ACK_DS                                                                        = 0x12, 
  /* local FDL/PHY not in token-ring                                      */ 
  ACK_NO                                                                        = 0x13, 
  /* ACK. negative:   not ok (different meanings dependant on service)    */ 
  ACK_LR                                                                        = 0x14, 
  /* resource of local FDL not available                                  */ 
  ACK_IV                                                                        = 0x15, 
  /* invalid parameter in request                                         */ 
  ACK_LO                                                                        = 0x20, 
  /* LOw-prior response-data are sent at this srd                         */ 
  ACK_HI                                                                        = 0x21, 
  /* HIgh-prior response-data are sent at this srd                        */ 
  ACK_NO_DATA                                                                   = 0x22                /* NO-DATA are sent at this srd                                         */ 
} TACK; 
 
 
 
 
/* 
typedef enum { 
    br9600,  
    br19200 
} TBaudRate; 
*/ 
 
 
typedef enum 
{ 
  No, 
  Local, 
  Remote 
}  TServiceType; 
 
 
//********************************************************************************** 
//********************************************************************************** 
//********************************************************************************** 
// 
// Standratni struktury pro FDL 
// 
 
/* ------------------- */ 
/* definitions for FLC */ 
/* ------------------- */ 
 
#define   FLC_Subsys    0x22 
 
#define   DEFAULT_SAP   0xff 
#define   EVENT_SAP     64 
#define   NO_SEGMENT    0xff 
#define   BROADCAST     127             /* broadcast-addr.: rem_add.station, dsap = 63  */ 
#define   MULTICAST     127             /* multicast-addr.: rem_add.station, dsap != 63 */ 
 
#define   LEN_MAX_RECEIVE_BUFFER  255    /* max. buffer-length for a receive telegram    */ 
#define   LEN_MIN_RECEIVE_BUFFER  32     /* min. receive_l_sdu.length                    */ 
 
#define   ALL                     0x7f 
#define   SEGMENT_VALID           0x80 
#define   SEGMENT_INVALID         0x00 
#define   SEGMENT_TYP             0x40 
 
/* example */ 
/*   access_sap = ALL or sap_number;                                                */ 
/*   access_station = (ALL or station_number) + (SEGMENT_VALID or SEGMENT_INVALID); */ 
/*   if SEGMENT_VALID: access_segment = SEGMENT_TYP + segment_number (0 ... 63);    */ 
 
/* SERVICE */ 
#define   SDA_RESERVED            0x00 
#define   SDN_RESERVED            0x01 
#define   SRD_RESERVED            0x03 
#define   CSRD_RESERVED           0x05 
 
/* ROLE */ 
#define   INITIATOR               0x00            /* only possible by "sap_activate"                                      */ 
#define   RESPONDER               0x10            /* possible by "sap_activate" and mandatory by "rsap_activate"          */ 
#define   BOTH_ROLES              0x20            /* only possible by "sap_activate"                                      */ 
#define   SERVICE_NOT_ACTIVATED   0x30            /* service not activated                                                */ 
 
 
#define   STATION_PASSIVE         0x00 
#define   STATION_NON_EXISTANT    0x10 
#define   STATION_NON_EXISTENT    0x10 
#define   STATION_ACTIVE_READY    0x20 
#define   STATION_ACTIVE          0x30 
 
#define   LEN_SAP_ACTIVATE        sizeof(struct fdl_sap) 
#define   LEN_EVENT_INDICATION    sizeof(struct event_indication) 
 
typedef enum 
{ 
  flc_false, 
  flc_true 
}  flc_boolean; 
 
enum  com_class 
{ 
  request       = 0x00, 
  confirm       = 0x01, 
  indication    = 0x02 
}; 
 
enum  service_code 
{ 
  sda                         = 0x00, 
  // Send Data with Acknowledge                         
  sdn                         = 0x01, 
  // Send Data with no Acknowledge                      
  sdn_broadcast               = 0x7f, 
  // only for FDL-indication !!! (signs received broadcast-telegram)       
  srd                         = 0x03, 
  // Send and Request Data                              
  csrd                        = 0x05, 
  // Cyclic Send and Request Data                       
  reply_update_single         = 0x06, 
  // Reply Update Single Mode                           
  reply_update_multiple       = 0x07, 
  // Reply Update Multiple Mode                         
  fdl_read_value              = 0x0b, 
  // read busparameter                                  
  fdl_set_value               = 0x0c, 
  // set busparameter                                   
  sap_activate                = 0x0e, 
  // activate local SAP                                 
  rsap_activate               = 0x11, 
  // activate local Responder-SAP                       
  sap_deactivate              = 0x12, 
  // deactivate local (R)SAP                            
  fdl_reset                   = 0x13, 
  // reset PHY and FDL; all FDL-information is lost, exc. last busparam.   
  mac_reset                   = 0x15, 
  // reset for MAC; a part of last valid busparameter will be updated      
  fdl_event                   = 0x18, 
  // only for indication, list of events                
  lsap_status                 = 0x19, 
  // requests information of remote-SAP or local-SAP    
  fdl_life_list_create_remote = 0x1a, 
  // requests list of intact stations                   
  fdl_life_list_create_local  = 0x1b, 
  // requests quick-list of intact stations (LAS and GAP will be actual)   
  fdl_ident                   = 0x1c, 
  // requests data of software- and hardware-release    
  fdl_read_statistic_ctr      = 0x1d, 
  // NOT SUPPORTED! reads counter values of statistic and resets counter                  
  fdl_read_las_statistic_ctr  = 0x1e, 
  // NOT SUPPORTED! reads LAS and las_cycle_ctr and resets las_cycle_ctr                  
  await_indication            = 0x1f, 
  // provides resources for indication (sap-dependent)  
  withdraw_indication         = 0x20, 
  // returnes indication-resources                      
  load_routing_table          = 0x21, 
  // only for network-connection !!!                    
  deactivate_routing_table    = 0x22, 
  // only for network-connection !!!                    
  get_direct_conn             = 0x23, 
  // gets adress of next station                        
}; 
 
typedef enum 
{ 
  low     = 0x00, 
  high    = 0x01 
} service_class; 
 
enum  link_status 
{ 
  ok       = 0x00, 
  // ACK. positive                             
  ue       = 0x01, 
  // ACK. negative:   remote-USER/FDL interface error                      
  rr       = 0x02, 
  // ACK. negative:   no remote resource available                         
  rs       = 0x03, 
  // ACK. negative:   service or rem_add at remote-lsap not activated      
  dl       = 0x08, 
  // response-data (l_sdu) low available       
  nr       = 0x09, 
  // ACK. negative:   no response-data at remote-FDL available             
  dh       = 0x0a, 
  // response-data (l_sdu) high available      
  rdl      = 0x0c, 
  // response-data (l_sdu) low available, but negative-ACK for send-data   
  rdh      = 0x0d, 
  // response-data (l_sdu) high available, but negative-ACK for send-data  
  ls       = 0x10, 
  // service not activated at local sap        
  na       = 0x11, 
  // no reaction (ACK/RES) from remote-station 
  ds       = 0x12, 
  // local FDL/PHY not in token-ring           
  no       = 0x13, 
  // ACK. negative:   not ok (different meanings dependant on service)     
  lr       = 0x14, 
  // resource of local FDL not available       
  iv       = 0x15, 
  // invalid parameter in request              
  lo       = 0x20, 
  // LOw-prior response-data are sent at this srd                          
  hi       = 0x21, 
  // HIgh-prior response-data are sent at this srd                         
  no_data  = 0x22                 
  // NO-DATA are sent at this srd              
}; 
 
enum    poll_element_entry 
{ 
  unlocked    = 0x00, 
  // polling enabled for this element          
  locked      = 0x01, 
  // element locked for this poll-cycle        
  not_changed = 0x02                 
  // the same meaning as "unlocked", but layer 2 doesn't plausible this    
  // service; use only, if this element has already been sent and no       
  // parameter changed, but actualize receive_l_sdu.length !!!!!!!!!       
}; 
 
 
 
typedef enum 
{ 
  passive                                                                       = 0x00, 
  active                                                                        = 0x01, 
  active_fast                                                                   = 0x02, 
  passive_fast                                                                  = 0x03, 
  sm_active                                                                     = 0x04, 
  /* possible returned by read_value (PROFIBUS-PA)                        */ 
  sm_passive                                                                    = 0x05 
}  station_type ; 
 
typedef enum 
{ 
  kbaud_9_6         = 0x00, 
  kbaud_19_2        = 0x01, 
  kbaud_93_75       = 0x02, 
  kbaud_187_5       = 0x03, 
  kbaud_500         = 0x04, 
  kbaud_375         = 0x05, 
  kbaud_750         = 0x06, 
  /*CT_CHANGE*/ 
  mbaud_1_5         = 0x07, 
  mbaud_3           = 0x08, 
  mbaud_6           = 0x09, 
  mbaud_12          = 0x0a, 
  kbaud_45_45       = 0x0c                /* 09-06-1997: a new baud rate */ 
}  baud_rate; 
 
enum    redundancy 
{ 
  no_redundancy       = 0x00, 
  bus_a_highprior     = 0x01, 
  bus_b_highprior     = 0x02, 
  redundancy_on       = 0x03 
}; 
 
enum    physical_layer 
{ 
  rs485     = 0x00, 
  modem     = 0x01 
}; 
 
enum    false_bus_parameter             /* "fdl_set_value" : if FDL-User sets false bus_parameter,              */ 
/* application_block -> l_status = false_bus_parameter + iv;            */ 
/* that means, high-fesponds with number of false parameter     */ 
{ 
  false_hsa                       = 0x100, 
  false_ts                        = 0x200, 
  false_station_type              = 0x300, 
  false_baud_rate                 = 0x400, 
  false_medium_red                = 0x500, 
  false_retry_ctr                 = 0x600, 
  false_default_sap               = 0x700, 
  false_network_connection_sap    = 0x800, 
  false_tsl                       = 0x900, 
  false_tqui                      = 0xa00, 
  false_tset                      = 0xb00, 
  false_min_tsdr                  = 0xc00, 
  false_max_tsdr                  = 0xd00, 
  false_ttr                       = 0xe00, 
  false_g                         = 0xf00, 
  false_in_ring_desired           = 0x1000, 
  false_physical_layer            = 0x1100, 
  false_ident                     = 0x1200 
}; 
 
//----------------------------------------------- 
 
typedef struct 
{ 
#ifdef M_DOS 
   enum  service_code      code; 
#else 
   short                   code; 
#endif     
}service; 
 
 
typedef struct 
{ 
    UCHAR station; 
    UCHAR segment;              // if no segment is used, set "NO_SEGMENT" 
}remote_address; 
 
typedef struct 
{ 
    void                    * buffer_ptr; 
    UCHAR                     length; 
}link_service_data_unit; 
 
 
typedef struct 
{ 
    UCHAR                   opcode;         /* class of communication                                               */ 
    UCHAR                   subsystem;      /* number of source-task (only necessary for MTK-user !!!!!)            */ 
    UWORD                   id;             /* identification of FDL-USER                                           */ 
    service                 service;        /* identification of service                                            */ 
    remote_address          loc_add;        /* only for network-connection !!!                                      */ 
    UCHAR                   ssap;           /* source-service-access-point                                          */ 
    UCHAR                   dsap;           /* destination-service-access-point                                     */ 
    remote_address          rem_add;        /* address of the remote-station                                        */ 
#ifdef M_DOS 
    enum    service_class          serv_class;     /* priority of service                                           */ 
#else  
    short                          serv_class;     /* priority of service                                           */ 
#endif     
    link_service_data_unit  receive_l_sdu;  /* address and length of received netto-data, exception:                */ 
    UCHAR                   reserved1;      /* (reserved for FDL !!!!!!!!!!)                                        */ 
    UCHAR                   reserved2;      /* (reserved for FDL !!!!!!!!!!)                                        */ 
    link_service_data_unit  send_l_sdu;     /* address and length of send-netto-data, exception:                    */ 
    /* 1. csrd                 : length means number of POLL-elements       */ 
    /* 2. await_indication     : concatenation of application-blocks and    */ 
    /*    withdraw_indication  : number of application-blocks               */ 
#ifdef M_DOS 
    enum    link_status            l_status;       /* link-status of service or update_state for srd-indication            */ 
#else 
    short                          l_status;       /* link-status of service or update_state for srd-indication            */ 
#endif     
    UCHAR                   reserved3[4];   /* for concatenated lists       (reserved for FDL !!!!!!!!!!)           */ 
}application_block; 
 
typedef struct 
{ 
    UWORD reserved[2]; 
    UCHAR length; 
    UWORD user; 
    UCHAR rb_type; 
    UCHAR priority; 
    UCHAR reserved_1; 
    UWORD reserved_2; 
    UCHAR subsystem; 
    UCHAR opcode; 
    UWORD response; 
    UWORD fill_length_1; 
    UCHAR reserved_3; 
    UWORD seg_length_1; 
    UWORD offset_1; 
    UWORD reserved_4; 
    UWORD fill_length_2; 
    UCHAR reserved_5; 
    UWORD seg_length_2; 
    UWORD offset_2; 
    UWORD reserved_6; 
} rb2_header_type; 
 
 
typedef struct 
{ 
    rb2_header_type   rb2_header; 
    application_block application_block; 
    UCHAR             reserved[12]; 
    UCHAR             reference[2]; 
    UCHAR             user_data_1[260]; 
    UCHAR             user_data_2[260]; 
} fdl_rb; 
 
 
typedef fdl_rb    flc_rb; 
 
/* Moegliche Strukturen der Datenpuffer */ 
 
struct  user_poll_element 
{ 
    UCHAR                       dsap;          /* destination-service-access-point                                     */ 
    remote_address              rem_add;       /* address of the remote-station                                        */ 
#ifdef M_DOS 
    enum    service_class           serv_class;    /* priority of send-telegram                                        */ 
#else 
    short                           serv_class;    /* priority of send-telegram                                        */ 
#endif     
    link_service_data_unit      receive_l_sdu; /* request: length means buffer-length in byte                          */ 
    /* confirm: length means length of received netto-data                  */ 
    link_service_data_unit      send_l_sdu;    /* address and length of send-netto-data                                */ 
    UCHAR                       reserved;      /* reserved for FDL !!!!!                                               */ 
#ifdef M_DOS 
    enum    link_status             l_status;      /* link-status of poll-element-service                                  */ 
    enum    poll_element_entry      entry;         /* locks or unlocks a poll-element                                      */ 
#else 
    short                           l_status;      /* link-status of poll-element-service                                  */ 
    short                           entry;         /* locks or unlocks a poll-element                                      */ 
#endif 
    UCHAR                       reserved_2;    /* reserved for FDL !!!!!                                               */ 
}; 
 
 
typedef struct ident 
{ 
    UCHAR reserved_header[8];                    /* reserved for FDL !!!!!                                               */ 
    UBYTE   ident[202]; 
    UCHAR response_telegram_length;              /* reserved for FDL !!!!!                                               */ 
}; 
 
 
struct  bus_parameter_block 
{ 
    UCHAR                   hsa;                  /* highest station-address                                              */ 
    /* range of values:  2 ... 126                                          */ 
    UCHAR                   ts;                   /* FDL-address of this station                                          */ 
    /* range of values:  0 ... 126                                          */    
#ifdef M_DOS 
    enum    station_type    stat_type;          /* active, passive                                                      */ 
    enum    baud_rate       Baud_Rate;             /* transmission rate                                                    */ 
    enum    redundancy      medium_red;            /* availability of redundant media                                      */ 
#else 
    short                   stat_type;          /* active, passive                                                      */ 
    short                   Baud_Rate;             /* transmission rate                                                    */ 
    short                   medium_red;            /* availability of redundant media                                      */ 
#endif     
    UWORD                   retry_ctr;            /* retry-number of requestor, if no reaction of responder               */ 
    /* range of values:  1 ... 8                                            */ 
    UCHAR                   default_sap;          /* Default SAP if no address-extension is used                          */ 
    /* range of values:  2 ... 62                                           */ 
    UCHAR                   network_connection_sap;/* number of sap for network-connection (only for network-connections) */ 
    /* range of values:  2 ... 62                                           */ 
    UWORD                   tsl;                  /* SLOT-time:                                                           */ 
    /* range of values:  2 exp 0 ... (2 exp 16) - 1   BIT-times             */ 
    UWORD                   tqui;                 /* Transmitter-Fall-Time / Repeater-Switch-Time:                        */ 
    /* range of values:  0 ... (2 exp 8) - 1 BIT-times                      */ 
    UWORD                   tset;                 /* setup-time                                                           */ 
    /* range of values:  0 ... (2 exp 8) - 1 BIT-times                      */ 
    UWORD                   min_tsdr;             /* smallest STATION-DELAY-time:                                         */ 
    /* range of values:  2 exp 0 ... (2 exp 16) - 1   BIT-times             */ 
    UWORD                   max_tsdr;             /* largest STATION-DELAY-time:                                          */ 
    /* range of values:  2 exp 0 ... (2 exp 16) - 1   BIT-times             */ 
    ULONG                   ttr;                  /* TARGET-ROTATION-time:                                                */ 
    /* range of values:  2 exp 0 ... (2 exp 24) - 1   BIT-times             */ 
    UCHAR                   g;                    /* GAP-UPDATE-factor: in multiples of ttr                               */ 
    /* range_of_values:  1 ... 100                                          */ 
#ifdef M_DOS 
    flc_boolean             in_ring_desired;       /* request entrance into the token-ring                                 */ 
    enum    physical_layer  physical_layer;        /* RS485, modem                                                         */ 
#else 
  short               in_ring_desired;       /* request entrance into the token-ring                                 */ 
  short                   physical_layer;        /* RS485, modem                                                         */ 
#endif     
    struct  ident           ident;                 /* vendor-name, controller_type, version of hardware and software       */ 
} bus_parameter_block; 
 
struct fdl_sap 
{ 
    UWORD                   user_id;                /* identification for user                                              */ 
    UCHAR                   max_l_sdu_length;       /* maximal length of netto_data for this sap                            */ 
    UCHAR                   access_sap;             /* reserved destination_sap                                             */ 
    UCHAR                   access_station;         /* reserved destination_address                                         */ 
    UCHAR                   access_segment;         /* reserved destination_segment                                         */ 
    UCHAR                   sda;                    /* ... .sda = "ROLE"; sda unused by service "rsap_activate"             */ 
    UCHAR                   sdn;                    /* look sda; sdn unused by service "rsap_activate"                      */ 
    UCHAR                   srd;                    /* look sda;                                                            */ 
    UCHAR                   csrd;                   /* if you want to activate csrd for this SAP, type: ... .csrd = "ROLE"; */ 
    /* (only INITIATOR or SERVICE_NOT_ACTIVATED possible)                   */ 
    /* csrd unused by service "rsap_activate"                               */ 
    void                  * rup_l_sdu_ptr_low;      /* reserved for "sap_deactivate"; USER gets rup-buffer returned         */ 
    void                  * rup_l_sdu_ptr_high;     /* reserved for "sap_deactivate"; USER gets rup-buffer returned         */ 
    UCHAR                   reserved[22];           /* reserved for FDL !!!!!                                               */ 
}; 
 
struct fdl_l_stat 
{ 
    UCHAR access_station;         /* reserved destination_address                                         */ 
    UCHAR reserved; 
    UCHAR sda;                    /* ... .sda = "ROLE"; sda unused by service "rsap_activate"             */ 
    UCHAR sdn;                    /* look sda; sdn unused by service "rsap_activate"                      */ 
    UCHAR srd;                    /* look sda;                                                            */ 
    UCHAR csrd;                   /* if you want to activate csrd for this SAP, type: ... .csrd = "ROLE"; */ 
}; 
/**********************************************************************/ 
/****************   fdl_event (returned by fma_indication) ************/ 
/****************   await_indication (for DSAP = EVENT_SAP)************/ 
/**********************************************************************/ 
 
 
struct  event_ctr 
{ 
    UWORD threshold;                      /* if counter achieves threshold, a fma_indication is initiated         */ 
    UWORD counter; 
}; 
 
struct event_indication 
{ 
    struct  event_ctr time_out; 
    struct  event_ctr not_syn; 
    struct  event_ctr uart_error; 
    struct  event_ctr out_of_ring; 
    struct  event_ctr sdn_not_indicated; 
    struct  event_ctr duplicate_address; 
    struct  event_ctr hardware_error; 
    struct  event_ctr mac_error; 
    UCHAR             priority; 
} ; 
 
 
/**********************************************************************/ 
/****************   fdl_read_statistic_ctr  ***************************/ 
/**********************************************************************/ 
 
struct statistic_ctr_list 
{ 
    /* error-counter */ 
    UWORD invalid_start_delimiter_ctr; 
    UWORD invalid_fcb_fcv_ctr; 
    UWORD invalid_token_ctr; 
    UWORD collision_ctr; 
    UWORD wrong_fcs_or_ed_ctr; 
    UWORD frame_error_ctr; 
    UWORD char_error_ctr; 
    UWORD retry_ctr; 
    /* reference-counter */ 
    ULONG start_delimiter_ctr; 
    ULONG stop_receive_ctr; 
    ULONG send_confirmed_ctr; 
    ULONG send_sdn_ctr; 
}; 
 
 
 
#ifndef INLINE 
  #define INLINE __inline 
#endif 
 
#ifndef CHIP950 
  #define CHIP950 (DeviceExtension->chip_options&(~0xff))==0x16954000 
#endif 
 
 
 
#endif /*_VARDEF_H */