Compare commits

...

26 Commits

Author SHA1 Message Date
Jeff Hill
e783ec0de9 added cinst to pformat decl so we match ansi C 1995-02-18 01:51:38 +00:00
Jeff Hill
23f970b821 const added to pformat declartion so we match ansi C 1995-02-18 01:50:07 +00:00
Jeff Hill
7ff04ea451 ansi C 1995-02-18 01:48:31 +00:00
Jeff Hill
fd9d79f445 epicsPrintf() changes 1995-02-18 01:41:12 +00:00
Marty Kraimer
a12e94cffb Forgot to remove mprintf.h 1995-02-17 20:59:30 +00:00
Marty Kraimer
d38eaf82cd Clean up errPrintf stuff 1995-02-17 20:55:09 +00:00
Marty Kraimer
b1382c3f19 All err init done by errInit 1995-02-17 20:50:21 +00:00
Jeff Hill
7eaeac2075 ansi C 1995-02-17 20:44:02 +00:00
Jeff Hill
96defa3afa use arch independent types 1995-02-17 20:43:32 +00:00
Jeff Hill
4b2f0c1d74 doc 1995-02-17 20:41:16 +00:00
Jeff Hill
53bfe9888a new model names 1995-02-17 20:40:27 +00:00
Jeff Hill
2c82e2976c use empty host name if os query fails 1995-02-17 20:10:46 +00:00
Jeff Hill
ea2efa0e47 fixed comment 1995-02-17 20:09:25 +00:00
Jeff Hill
bd5b7b61a0 Use empty user name if we cant query the os 1995-02-17 20:08:51 +00:00
Jeff Hill
6d2eafd2ca No ENV_PRIVATE_DATA alloc here and empty user name if query fails 1995-02-17 20:07:06 +00:00
Jeff Hill
67b4dc7064 added convert.c to the UNIX build 1995-02-17 20:05:23 +00:00
Janet B. Anderson
f3ad1f4d4e Initial version 1995-02-17 15:09:56 +00:00
Jeff Hill
0eb9331f88 NT changes 1995-02-16 22:35:44 +00:00
Jeff Hill
35b0e4aaba NT changes and (long) cast problem fixed 1995-02-16 22:34:06 +00:00
Ned Arnold
1ea57db276 changed name of caMonitor.c to recWaitCa.c 1995-02-16 20:36:59 +00:00
Ned Arnold
062e3d6d32 changed names of caMonitor stuff to recWaitCa stuff. Also added
individual flags for IO_INTR processing of inputs
1995-02-16 20:18:22 +00:00
Jim Kowalkowski
6937834dee Rewrote a suspicious looking loop. 1995-02-16 17:08:48 +00:00
Janet B. Anderson
f9793ec277 Initial version 1995-02-15 17:13:23 +00:00
John Winans
a93e2e8b26 Cleaned up some Hideos hacking and commented out the LANL debug code because
APS has had some add behaviour from GPIB lately and it is one of few things
that has changed WRT to it.
1995-02-14 22:33:01 +00:00
Marty Kraimer
d7275641dc Revert to previous version of dbpf 1995-02-14 19:57:38 +00:00
cvs2svn
9dc64d0063 This commit was manufactured by cvs2svn to create tag 'R3.12.0-beta7'. 1995-02-13 21:44:50 +00:00
36 changed files with 1208 additions and 724 deletions

29
README.solaris Normal file
View File

@@ -0,0 +1,29 @@
----------------------------------------------------------------------------
EPICS R3.12 Notes for Solaris 2.3
- By Andrew Johnson
----------------------------------------------------------------------------
Notes:
1. In order to build and use EPICS under Solaris 2, you must include
various directories in your path in the order given below, in addition
to those named in base/README. Some of these directories may already be
included in your path from your .login script or .cshrc file, so be
careful that the ordering is correct.
setenv PATH /usr/ucb:/usr/bin:/usr/ccs/bin:$PATH
2. It is not possible to compile the whole of EPICS under Solaris 2
using only the GNU gcc compiler - some routines which are needed (for
example quiet_nan()) have been unbundled by Sun and are provided with
their ANSI C compiler. The path to the Sun compiler is explicitly set
using the SPARCWORKS definition in the file CONFIG_SITE.Unix.solaris
3. EPICS must be compiled and linked using the UCB compatability
libraries. The definitions UCB_LIB and UCB_INCLUDE are used here to
refer to these libraries and their header files, and the tools provided
within /usr/ucb must be used in preference to the System V ones, hence
the above path ordering.
--
anj@mail.ast.cam.ac.uk

View File

@@ -52,10 +52,9 @@ IF_DEPEN, -
VMS_DEPEN, -
ELLLIB, -
BUCKETLIB, -
NEXTFIELDSUBR, -
ENVSUBR, -
TSSUBR, -
GENSUBR, -
NEXTFIELDSUBR, -
CATIME, -
ACCTST
$ endif
@@ -76,10 +75,9 @@ IF_DEPEN, -
VMS_DEPEN, -
BSD_DEPEN, -
BUCKETLIB, -
NEXTFIELDSUBR, -
TSSUBR, -
ENVSUBR, -
GENSUBR, -
NEXTFIELDSUBR, -
ELLLIB
$! Link the test programs
$ call link acctst

View File

@@ -15,14 +15,15 @@ SRCS.c = \
../iocinf.c ../access.c ../test_event.c ../service.c \
../flow_control.c ../repeater.c ../conn.c \
../syncgrp.c ../if_depen.c ../netdb_depen.c ../bsd_depen.c \
../posix_depen.c ../caRepeater.c ../acctst.c ../catime.c
../posix_depen.c ../caRepeater.c ../acctst.c ../catime.c \
../convert.c
OBJS = caRepeater.o
LIBOBJS = \
iocinf.o access.o test_event.o service.o flow_control.o repeater.o \
conn.o syncgrp.o if_depen.o netdb_depen.o \
bsd_depen.o posix_depen.o
bsd_depen.o posix_depen.o convert.o
LIBNAME = libca.a

View File

@@ -134,6 +134,7 @@ static char *sccsId = "@(#) $Id$";
#include "iocinf.h"
#include "net_convert.h"
#include <epicsPrint.h>
#include <stdarg.h> /* for VMS old CC include order madness */
@@ -559,7 +560,7 @@ int ca_os_independent_init (void)
sec = (unsigned) CA_RECAST_DELAY;
ca_static->ca_conn_retry_delay.tv_sec = sec;
ca_static->ca_conn_retry_delay.tv_usec =
(long) (CA_RECAST_DELAY-sec)*USEC_PER_SEC;
(long) ((CA_RECAST_DELAY-sec)*USEC_PER_SEC);
ellInit(&ca_static->ca_iiuList);
ellInit(&ca_static->ca_ioeventlist);
@@ -1109,7 +1110,7 @@ int APIENTRY ca_search_and_connect
sec = (int) CA_RECAST_DELAY;
ca_static->ca_conn_retry_delay.tv_sec = sec;
ca_static->ca_conn_retry_delay.tv_usec =
(long) (CA_RECAST_DELAY-sec)*USEC_PER_SEC;
(long) ((CA_RECAST_DELAY-sec)*USEC_PER_SEC);
UNLOCK;
@@ -2722,11 +2723,11 @@ int APIENTRY ca_pend(ca_real timeout, int early)
/*
* Allow for CA background labor
*/
remaining = (long) min(SELECT_POLL, remaining);
remaining = min(SELECT_POLL, remaining);
}
tmo.tv_sec = (long) remaining;
tmo.tv_usec = (long) (remaining-tmo.tv_sec)*USEC_PER_SEC;
tmo.tv_usec = (long) ((remaining-tmo.tv_sec)*USEC_PER_SEC);
cac_block_for_io_completion(&tmo);
}
}
@@ -3384,7 +3385,7 @@ int ca_channel_status(int tid)
* ca_replace_printf_handler ()
*/
int APIENTRY ca_replace_printf_handler (
int (*ca_printf_func)(char *pformat, va_list args)
int (*ca_printf_func)(const char *pformat, va_list args)
)
{
if (ca_printf_func) {
@@ -3406,13 +3407,13 @@ int (*ca_printf_func)(char *pformat, va_list args)
*/
int ca_printf(char *pformat, ...)
{
int (*ca_printf_func)(char *pformat, va_list args);
int (*ca_printf_func)(const char *pformat, va_list args);
va_list theArgs;
int status;
va_start(theArgs, pformat);
ca_printf_func = ca_default_printf;
ca_printf_func = epicsVprintf;
if (ca_static) {
if (ca_static->ca_printf_func) {
ca_printf_func = ca_static->ca_printf_func;
@@ -3426,21 +3427,3 @@ int ca_printf(char *pformat, ...)
return status;
}
/*
* ca_default_printf()
* (this default is replaced under vxWorks
* - see vxWorks_depen.c)
*/
int ca_default_printf(char *pformat, va_list args)
{
int status;
status = vfprintf(
stderr,
pformat,
args);
return status;
}

View File

@@ -9,9 +9,14 @@ static char *sccsId = "@(#) $Id$";
#include <LIB$ROUTINES.H>
#endif
/*
* ANSI
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include "os_depen.h"
@@ -219,22 +224,22 @@ int doacctst(char *pname)
double dval = 3.3;
float fval = -8893.3;
double dret;
float fret;
double dret = DBL_MAX;
float fret = FLT_MAX;
status = ca_put(DBR_DOUBLE, chix1, &dval);
SEVCHK(status, NULL);
status = ca_get(DBR_DOUBLE, chix1, &dret);
SEVCHK(status, NULL);
ca_pend_io(30.0);
assert(dval - dret < .000001);
assert( fabs(dval-dret) < DBL_EPSILON*4);
status = ca_put(DBR_FLOAT, chix1, &fval);
SEVCHK(status, NULL);
status = ca_get(DBR_FLOAT, chix1, &fret);
SEVCHK(status, NULL);
ca_pend_io(30.0);
assert(fval - fret < .0001);
assert( fabs(fval-fret) < FLT_EPSILON*4);
}
/*

View File

@@ -469,7 +469,7 @@ void mark_server_available(struct in_addr *pnet_addr)
delay += CA_RECAST_DELAY;
idelay = (long) delay;
ca_delay.tv_sec = idelay;
ca_delay.tv_usec = (long) (delay-idelay) * USEC_PER_SEC;
ca_delay.tv_usec = (long) ((delay-idelay) * USEC_PER_SEC);
next = cac_time_sum(&currentTime, &ca_delay);
diff = cac_time_diff(

View File

@@ -1592,7 +1592,7 @@ void ntohf(float *pNet, float *pHost)
#endif /*CA_FLOAT_MIT*/
#if !defined(CA_FLOAT_MIT)
#if defined(CA_FLOAT_IEEE) && 0
/*
* htond ()
@@ -1600,6 +1600,7 @@ void ntohf(float *pNet, float *pHost)
*/
void htond (double *IEEEhost, double *IEEEnet)
{
#ifdef CA_LITTLE_ENDIAN
ca_uint32_t *pHost = (ca_uint32_t *) IEEEhost;
ca_uint32_t *pNet = (ca_uint32_t *) IEEEnet;
ca_uint32_t tmp;
@@ -1612,6 +1613,9 @@ void htond (double *IEEEhost, double *IEEEnet)
tmp = pHost[0];
pNet[0] = htonl (pHost[1]);
pNet[1] = htonl (tmp);
#else
*IEEEnet = *IEEEhost;
#endif
}
/*
@@ -1620,6 +1624,7 @@ void htond (double *IEEEhost, double *IEEEnet)
*/
void ntohd (double *IEEEnet, double *IEEEhost)
{
#ifdef CA_LITTLE_ENDIAN
ca_uint32_t *pHost = (ca_uint32_t *) IEEEhost;
ca_uint32_t *pNet = (ca_uint32_t *) IEEEnet;
ca_uint32_t tmp;
@@ -1632,6 +1637,9 @@ void ntohd (double *IEEEnet, double *IEEEhost)
tmp = pNet[0];
pHost[0] = ntohl (pNet[1]);
pHost[1] = htonl (tmp);
#else
*IEEEhost = *IEEEnet;
#endif
}
/*
@@ -1658,7 +1666,7 @@ void htonf (float *IEEEhost, float *IEEEnet)
*pNet = htonl (*pHost);
}
#endif /* not CA_MIT_FLOAT*/
#endif /* IEEE float and little endian */

View File

@@ -219,7 +219,7 @@ int net_proto
IPPROTO_TCP,
TCP_NODELAY,
(char *)&true,
sizeof true);
sizeof(true));
if(status < 0){
free(piiu);
status = socket_close(sock);
@@ -443,7 +443,6 @@ int net_proto
piiu->host_name_str,
"<<unknown host>>",
sizeof(piiu->host_name_str)-1);
break;
default:
@@ -1514,6 +1513,8 @@ unsigned long cacRingBufferWriteSize(struct ca_buffer *pBuf, int contiguous)
* vxWorks user will need to configure a DNS format name for the
* host name if they wish to be cnsistent with UNIX and VMS hosts.
*
* this needs to attempt to determine if the process is a remote
* login - hard to do under UNIX
*/
char *localHostName()
{

View File

@@ -100,6 +100,7 @@ HDRVERSIONID(iocinfh, "$Id$")
#include <bucketLib.h>
#include <ellLib.h>
#include <envDefs.h>
#include <epicsPrint.h>
/*
* CA private includes
@@ -410,7 +411,7 @@ struct ca_static{
void (*ca_connection_func)
(struct connection_handler_args);
void *ca_connection_arg;
int (*ca_printf_func)(char *pformat, va_list args);
int (*ca_printf_func)(const char *pformat, va_list args);
void (*ca_fd_register_func)
(void *, SOCKET, int);
void *ca_fd_register_arg;
@@ -594,7 +595,6 @@ ca_time cac_time_sum(ca_time *pTVA, ca_time *pTVB);
void caIOBlockFree(evid pIOBlock);
void clearChannelResources(unsigned id);
void caSetDefaultPrintfHandler ();
int ca_default_printf(char *pformat, va_list args);
/*
* !!KLUDGE!!

View File

@@ -40,13 +40,14 @@ static char *sccsId = "@(#) $Id$";
#include <assert.h>
#ifdef _WINDOWS
#include <winsock.h>
# include <winsock.h>
#else
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <arpa/inet.h>
# include <netdb.h>
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
/*

View File

@@ -134,11 +134,8 @@ static char *os_depenhSccsId = "$Id$";
#endif
/*
* Big endin architecture is assumed. Otherwise set "CA_LITTLE_ENDIAN".
*
* IEEE floating point architecture assumed. Set "CA_FLOAT_MIT" if
* appropriate. No other floating point formats currently
* supported.
* Here are the definitions for architecture dependent byte ordering
* and floating point format
*/
#if defined(VAX)
# define CA_FLOAT_MIT

View File

@@ -210,7 +210,7 @@ char *localUserName()
if(!pName){
pName = getpwuid(getuid())->pw_name;
if(!pName){
return NULL;
pName = "";
}
}
@@ -279,6 +279,6 @@ void ca_spawn_repeater()
*/
void caSetDefaultPrintfHandler ()
{
ca_static->ca_printf_func = ca_default_printf;
ca_static->ca_printf_func = epicsVprintf;
}

View File

@@ -174,11 +174,7 @@ void cac_os_depen_exit (struct ca_static *pcas)
/*
*
* localUserName() - for VMS
*
* o Indicates failure by setting ptr to nill
*
*/
char *localUserName()
{
@@ -221,24 +217,13 @@ char *localUserName()
NULL,
NULL,
NULL);
if(status != SS$_NORMAL){
return NULL;
strcpy (pName, "");
}
/*
* test for remote login
*/
if(jobTypeSize != sizeof(jobType)){
return NULL;
}
/*
* This does not appear to change when it is
* a remote login ??
*/
if(jobType != JPI$K_LOCAL && jobType != JPI$K_DETACHED){
pTmp = "REMOTE";
return pTmp;
strcpy (pName, "");
}
/*
@@ -332,6 +317,6 @@ void caHostFromInetAddr(struct in_addr *pnet_addr, char *pBuf, unsigned size)
*/
void caSetDefaultPrintfHandler ()
{
ca_static->ca_printf_func = ca_default_printf;
ca_static->ca_printf_func = epicsVprintf;
}

View File

@@ -34,7 +34,6 @@
#include <callback.h>
#include "iocinf.h"
#include "remLib.h"
#include <mprintf.h>
LOCAL void ca_repeater_task();
LOCAL void ca_task_exit_tcb(WIND_TCB *ptcb);
@@ -892,6 +891,6 @@ void cac_recv_task(int tid)
*/
void caSetDefaultPrintfHandler ()
{
ca_static->ca_printf_func = vmprintf;
ca_static->ca_printf_func = epicsVprintf;
}

View File

@@ -2,6 +2,7 @@
* $Id$
* Author: Jeffrey O. Hill, Chris Timossi
* hill@luke.lanl.gov
* CATimossi@lbl.gov
* (505) 665 1831
* Date: 9-93
*
@@ -31,12 +32,22 @@
*
*/
/*
* Windows includes
*/
#include <process.h>
#include "iocinf.h"
#ifndef _WINDOWS
#error This source is specific to DOS/WINDOS
#endif
static int get_subnet_mask ( char SubNetMaskStr[256]);
static int RegTcpParams (char IpAddr[256], char SubNetMask[256]);
static int RegKeyData (CHAR *RegPath, HANDLE hKeyRoot, LPSTR lpzValueName,
LPDWORD lpdwType, LPBYTE lpbData, LPDWORD lpcbData );
/*
* cac_gettimeval
@@ -135,7 +146,8 @@ void cac_block_for_sg_completion(CASG *pcasg, struct timeval *pTV)
*/
int cac_os_depen_init(struct ca_static *pcas)
{
int status;
int status;
WSADATA WsaData;
ca_static = pcas;
@@ -146,16 +158,17 @@ int cac_os_depen_init(struct ca_static *pcas)
* allow error to be returned to sendto()
* instead of handling disconnect at interrupt
*/
signal(SIGPIPE,SIG_IGN);
/* signal(SIGPIPE,SIG_IGN); */
# ifdef _WINSOCKAPI_
status = WSAStartup(MAKEWORD(1,1), &WsaData));
status = WSAStartup(MAKEWORD(1,1), &WsaData);
assert (status==0);
# endif
status = ca_os_independent_init ();
return status;
return status;
}
@@ -180,12 +193,16 @@ void cac_os_depen_exit (struct ca_static *pcas)
*/
char *localUserName()
{
int length;
char *pName;
char *pTmp;
int length;
char *pName;
char *pTmp;
char Uname[] = "";
pName = "Joe PC";
length = strlen(pName)+1;
pName = getenv("USERNAME");
if (!pName) {
pName = Uname;
}
length = strlen(pName)+1;
pTmp = malloc(length);
if(!pTmp){
@@ -211,8 +228,13 @@ void ca_spawn_repeater()
* running in the repeater process
* if here
*/
pImageName = "caRepeater";
status = system(pImageName);
pImageName = "caRepeater.exe";
//status = system(pImageName);
//Need to check if repeater is already loaded
//For now, start Repeater from a command line, not here
status = 0;
//status = _spawnlp(_P_DETACH,pImageName,"");
if(status<0){
ca_printf("!!WARNING!!\n");
ca_printf("Unable to locate the executable \"%s\".\n",
@@ -229,15 +251,198 @@ void ca_spawn_repeater()
*/
void caSetDefaultPrintfHandler ()
{
ca_static->ca_printf_func = ca_default_printf;
ca_static->ca_printf_func = epicsVprintf;
}
/*
* DllMain ()
*
* Network interface routines
*
*/
BOOL APIENTRY DllMain (HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
/*
* local_addr()
*
* return 127.0.0.1
* (the loop back address)
*/
int local_addr (SOCKET s, struct sockaddr_in *plcladdr)
{
ca_uint32_t loopBackAddress = 0x7f000001;
plcladdr->sin_family = AF_INET;
plcladdr->sin_port = 0;
plcladdr->sin_addr.s_addr = ntohl (loopBackAddress);
return OK;
}
/*
* caDiscoverInterfaces()
*
* This routine is provided with the address of an ELLLIST a socket
* and a destination port number. When the routine returns there
* will be one additional inet address (a caAddrNode) in the list
* for each inet interface found that is up and isnt a loop back
* interface. If the interface supports broadcast then I add its
* broadcast address to the list. If the interface is a point to
* point link then I add the destination address of the point to
* point link to the list. In either case I set the port number
* in the address node to the port supplied in the argument
* list.
*
* LOCK should be applied here for (pList)
* (this is also called from the server)
*/
void caDiscoverInterfaces(ELLLIST *pList, SOCKET socket, int port)
{
struct sockaddr_in localAddr;
struct sockaddr_in InetAddr;
struct in_addr bcast_addr;
caAddrNode *pNode;
int status;
pNode = (caAddrNode *) calloc(1,sizeof(*pNode));
if(!pNode){
return;
}
broadcast_addr(&bcast_addr);
pNode->destAddr.inetAddr.sin_addr.s_addr = bcast_addr.s_addr; //broadcast addr
pNode->destAddr.inetAddr.sin_port = htons(port);
pNode->destAddr.inetAddr.sin_family = AF_INET;
//pNode->srcAddr.inetAddr = 0 ;//localAddr;
/*
* LOCK applied externally
*/
ellAdd(pList, &pNode->node);
}
int
broadcast_addr( struct in_addr *pcastaddr )
{
char netmask[256], lhostname[80];
static struct in_addr castaddr;
int status;
static char init = FALSE;
struct hostent *phostent;
unsigned long laddr;
if (init) {
*pcastaddr = castaddr;
return OK;
}
gethostname(lhostname,sizeof(lhostname));
phostent = gethostbyname(lhostname);
if (!phostent) {
return MYERRNO;
}
if (status = get_subnet_mask(netmask))
return ERROR;
laddr = *( (unsigned long *) phostent->h_addr_list[0]);
castaddr.s_addr = (laddr & inet_addr(netmask)) | ~inet_addr(netmask);
if (!init){
init = TRUE;
*pcastaddr = castaddr;
}
return OK;
}
static int get_subnet_mask ( char SubNetMaskStr[256])
{
char localadr[256];
return RegTcpParams (localadr, SubNetMaskStr);
}
static int RegTcpParams (char IpAddrStr[256], char SubNetMaskStr[256])
{
#define MAX_VALUE_NAME 128
static CHAR ValueName[MAX_VALUE_NAME];
static CHAR RegPath[256];
DWORD cbDataLen;
CHAR cbData[256];
DWORD dwType;
int status;
static char IpAddr[256], SubNetMask[256];
cbDataLen = sizeof(cbData);
strcpy(RegPath,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\\1");
status = RegKeyData (RegPath, HKEY_LOCAL_MACHINE, "ServiceName", &dwType, cbData, &cbDataLen);
if (status) {
strcpy(RegPath,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\\01");
status = RegKeyData (RegPath, HKEY_LOCAL_MACHINE, "ServiceName", &dwType, cbData, &cbDataLen);
if (status)
return status;
}
strcpy(RegPath,"SYSTEM\\CurrentControlSet\\Services\\");
strcat(RegPath,cbData);
strcat(RegPath,"\\Parameters\\Tcpip");
cbDataLen = sizeof(IpAddr);
status = RegKeyData (RegPath, HKEY_LOCAL_MACHINE, "IPAddress", &dwType, IpAddr, &cbDataLen);
if (status)
return status;
strcpy(IpAddrStr,IpAddr);
cbDataLen = sizeof(SubNetMask);
status = RegKeyData (RegPath, HKEY_LOCAL_MACHINE, "SubnetMask", &dwType, SubNetMask, &cbDataLen);
if (status)
return status;
strcpy(SubNetMaskStr,SubNetMask);
return 0;
}
static int RegKeyData (CHAR *RegPath, HANDLE hKeyRoot, LPSTR lpzValueName,
LPDWORD lpdwType, LPBYTE lpbData, LPDWORD lpcbData )
{
HKEY hKey;
DWORD retCode;
DWORD dwcClassLen = MAX_PATH;
// OPEN THE KEY.
retCode = RegOpenKeyEx (hKeyRoot, // Key handle at root level.
RegPath, // Path name of child key.
0, // Reserved.
KEY_QUERY_VALUE, // Requesting read access.
&hKey); // Address of key to be returned.
if (retCode)
{
//wsprintf (Buf, "Error: RegOpenKeyEx = %d", retCode);
return -1;
}
retCode = RegQueryValueEx (hKey, // Key handle returned from RegOpenKeyEx.
lpzValueName, // Name of value.
NULL, // Reserved, dword = NULL.
lpdwType, // Type of data.
lpbData, // Data buffer.
lpcbData); // Size of data buffer.
if (retCode)
{
//wsprintf (Buf, "Error: RegQIK = %d, %d", retCode, __LINE__);
return -2;
}
return 0;
}
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
int status;
WSADATA WsaData;
@@ -276,4 +481,3 @@ BOOL APIENTRY DllMain (HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
return TRUE;
}

View File

@@ -389,8 +389,21 @@ long dbpf(char *pname,char *pvalue)
errMessage(status,"dbNameToAddr error");
return(1);
}
status=dbPutField(&addr,DBR_STRING,pvalue,1L);
if(status) return(1);
/* For enumerated types must allow for ENUM rather than string*/
/* If entire field is digits then use DBR_ENUM else DBR_STRING*/
if((addr.dbr_field_type==DBR_ENUM) && (*pvalue!=0)
&& (strspn(pvalue,"0123456789")==strlen(pvalue))) {
short value;
sscanf(pvalue,"%hu",&value);
status=dbPutField(&addr,DBR_ENUM,&value,1L);
} else {
status=dbPutField(&addr,DBR_STRING,pvalue,1L);
}
if(status) {
errMessage(status,"dbPutField error");
return(1);
}
status=dbgf(pname);
return(status);
}

View File

@@ -148,13 +148,7 @@ int iocInit(char * pResourceFilename)
return(-1);
}
/*
* Build the data structure for error reporting
*/
if ((errSymBld()) != 0) {
logMsg("iocInit aborting because errSymBld failed to initialize \n",0,0,0,0,0,0);
return(-1);
}
errInit(); /*Initialize errPrintf task*/
/*
* Setup initialization hooks, but only if an initHooks routine has been defined.

View File

@@ -194,9 +194,8 @@ long dbInitSubst(char* parm_pattern)
case '\\': pp++; break; /* skip the next character */
case '=': subst_total++; break;
case '\"':
for(++pp;*pp && *pp!='\"';pp++);
if(*pp=='\\') pp++;
pp++;
for(++pp;*pp && *pp!='\"';pp++)
if(*pp=='\\') pp++;
break;
default: break;
}

View File

@@ -1,5 +1,6 @@
The CPU030 may need to have the nivxi path set correctly:
From the vxWorks shell type vxitedit
From the vxWorks shell type "vxitedit"
take option 2
take option 3
type list
@@ -8,6 +9,7 @@ The CPU030 may need to have the nivxi path set correctly:
(the path should end in nivxi
and should traverse the niCpu030
directories shipped with the 030
ie somethin of the form "???/config/niCPU030/nivxi"
type save
type exit
.

View File

@@ -450,10 +450,10 @@ struct at5vxi_model{
#define AT5VXI_MODEL_FROM_INDEX(INDEX) ((unsigned)((INDEX)|0xf00))
/*
NOTE: The macro AT5VXI_INDEX_FROM_MODEL(MODEL) defined above
should return an index into the correct data given the
VXI device's model code.
*/
* NOTE: The macro AT5VXI_INDEX_FROM_MODEL(MODEL) defined above
* should return an index into the correct data given the
* VXI device's model code.
*/
struct at5vxi_model at5vxi_models[] = {
{"INTERFACE SIMULATOR", "112Y-280158"},
{"I CONTROLLER", "112Y-280176"},
@@ -477,6 +477,16 @@ struct at5vxi_model at5vxi_models[] = {
{"DOWNCONVERTER", "112Y-280456"},
{"COAX MONITOR TRANSMITTER", "112Y-280587"},
{"CAVITY SIMULATOR", "112Y-280232"},
{"CABLE CONTROLLER (2 CHANNEL)","112Y-280539"},
{"BREADBOARD", "112Y-280358"},
{"I/O INTERFACE", "112Y-280359"},
{"DIAGNOSTIC - BPM", "112Y-280422-1"},
{"FAST ENVELOPE DETECTOR", "112Y-280421"},
{"DIAGNOSTIC - CM", "112Y-280422-2"},
{"DIAGNOSTIC - MISC", "112Y-280422-3"},
{"FAST VECTOR DETECTOR", "112Y-280651"},
{"SINGLE-WIDE VECTOR DETECTOR", "112Y-280672"},
{"FM / AM", "112Y-280xxx"}
};
#define AT5VXI_VALID_MODEL(MODEL) \

View File

@@ -62,6 +62,12 @@
*
*
* $Log$
* Revision 1.27 1994/12/14 22:29:14 winans
* Removed DMAC command chaining structure(s) from the ibLink
* structure so they can be malloc'd seperately. This keeps
* the usage of A24 space restricted to ONLY those structures
* that have to be there.
*
* Revision 1.26 1994/12/12 16:03:00 winans
* Rewrote the init code so that it always returns a zero (don't kill the
* startup.cmd file.) It is possible that this could cause some confusion
@@ -151,11 +157,11 @@ STATIC char *ram_base; /* Base of the ram on the CPU board */
STATIC int timeoutSquelch = 0; /* Used to quiet timeout msgs during polling */
/* DMA timing bus error problem debugging in niPhysIo */
int ibDmaDebug = 0; /* Turns on DMA debug messages from this driver */
int ibDmaTimingError = 0; /* count "bad memProbes"/call of niPhysIo */
int ibDmaTimingErrorTotal = 0; /* count total "bad memProbes" in niPhysIo */
int ibDmaMaxError = 0 ; /* max # bad calls per call of niPhysIo */
STATIC char testWrite; /* test char to write to 1014 card */
int ibDmaDebug = 0; /* Turns on DMA debug messages from this driver */
int ibDmaTimingError = 0; /* count "bad memProbes"/call of niPhysIo */
int ibDmaTimingErrorTotal = 0; /* count total "bad memProbes" in niPhysIo */
int ibDmaMaxError = 0; /* max # bad calls per call of niPhysIo */
STATIC char testWrite; /* test char to write to 1014 card */
/******************************************************************************
@@ -221,12 +227,7 @@ struct niLink {
WDOG_ID watchDogId; /* watchdog for timeouts */
struct ibregs *ibregs;/* pointer to board registers */
#if 0
char cc_byte;
struct cc_ary cc_array;
#else
DmaStuffStruct *DmaStuff;
#endif
char r_isr1;
char r_isr2;
@@ -1094,6 +1095,7 @@ int time; /* time to wait on the DMA operation */
else
b->ch1.ccr = D_EINT;
#ifdef INCLUDE_LANL_DMA_TIMING_CHECKER
/*************************************************************************
* DMAC BUS ERROR CATCH
* The following lines are included because of a possible VME protocol
@@ -1115,9 +1117,11 @@ int time; /* time to wait on the DMA operation */
logMsg("DMA timing: error = %d, total = %d, max = %d\n",
ibDmaTimingError, ibDmaTimingErrorTotal, ibDmaMaxError);
/***************************************************************************/
#endif
b->ch0.ccr = D_SRT;
#ifdef INCLUDE_LANL_DMA_TIMING_CHECKER
/****************************
* DMAC BUS ERROR CATCH
*****************************/
@@ -1131,6 +1135,7 @@ int time; /* time to wait on the DMA operation */
logMsg("DMA timing: error = %d, total = %d, max = %d\n",
ibDmaTimingError, ibDmaTimingErrorTotal, ibDmaMaxError);
/***************************************************************************/
#endif
b->imr2 = w_imr2; /* this must be done last */
@@ -2041,102 +2046,6 @@ int length; /* number of bytes to write out from the data buffer */
return(ERROR);
}
#ifdef INCLUDE_HIDEOS_INTERFACE
/******************************************************************************
*
* Interface functions for HiDEOS access.
*
******************************************************************************/
/******************************************************************************
*
* Read up to <length> bytes into <*buffer>.
*
******************************************************************************/
STATIC int
HideosGpibRead(struct ibLink *pibLink, int device, char *buffer, int length, int time)
{
logMsg("HideosGpibRead() entered\n");
return(bytes read | error);
}
/******************************************************************************
*
* Write <length> bytes from <*buffer> in data mode.
*
******************************************************************************/
STATIC int
HideosGpibWrite(struct ibLink *pibLink, int device, char *buffer, int length, int time)
{
logMsg("HideosGpibWrite() entered\n");
return(bytes sent | error);
}
/******************************************************************************
*
* Write <length> bytes from <*buffer> in command mode.
*
******************************************************************************/
STATIC int
HideosGpibCmd(struct ibLink *pibLink, char *buffer, int length)
{
logMsg("HideosGpibCmd() entered\n");
return(bytes sent | error);
}
/******************************************************************************
*
* Verify that the given GPIB port exists.
*
******************************************************************************/
STATIC int
HideosGpibCheckLink(int link, int bug)
{
logMsg("HideosGpibCheckLink() entered\n");
return(OK | ERROR);
}
/******************************************************************************
*
* Prevent SRQs from being polled on a given GPIB port.
*
******************************************************************************/
STATIC int
HideosGpibSrqPollInhibit(int link, int bug, int gpibAddr)
{
logMsg("HideosGpibSrqPollInhibit() entered -- NOT SUPPORTED YET\n");
return(ERROR);
}
/******************************************************************************
*
* Generate a GPIB link for a HiDEOS port.
*
******************************************************************************/
STATIC int
HideosGpibGenLink(int link, int bug)
{
logMsg("HideosGpibGenLink() entered\n");
return(ibLinkStart() | ERROR);
}
/******************************************************************************
*
* Handle a GPIB IOCTL call.
*
******************************************************************************/
STATIC int
HideosGpibIoctl(int link, int bug, int cmd, int v, caddr_t p)
{
logMsg("HideosGpibIoctl() entered\n");
return(OK | ERROR);
}
/******************************************************************************
*
* Given the port information, return a link structure.
*
******************************************************************************/
struct bbIbLink *
HideosGpibFindLink(int link, int bug)
{
logMsg("HideosGpibFindLink() entered\n");
return(bbIbLink* | NULL);
}
#endif
/******************************************************************************
*
* These are the BitBus architecture specific functions.
@@ -2674,9 +2583,9 @@ IBHistDump(int type, int link, int bug)
}
#endif
#if 1
#if 0
/* A way to stop the CPU when idle... run from shell at prio 250 */
BigFFT()
cpuStopperThingy()
{
while (1)
asm(" stop #0x3000");

View File

@@ -11,7 +11,7 @@ SRCS.c = \
../gpHashLib.c ../memDebugLib.c \
../nextFieldSubr.c ../postfix.c \
../tsSubr.c errSymTbl.c ../errInc.c \
../realpath.c ../mprintf.c
../realpath.c ../errPrintfUNIX.c
LIBOBJS = \
tsSubr.o bucketLib.o calcPerform.o\
@@ -19,7 +19,7 @@ LIBOBJS = \
envSubr.o errMtst.o errSymLib.o errSymTbl.o fdmgr.o \
freeListLib.o gpHashLib.o \
memDebugLib.o nextFieldSubr.o postfix.o \
realpath.o mprintf.o
realpath.o errPrintfUNIX.o
LIBNAME = libCom.a

View File

@@ -8,14 +8,14 @@ SRCS.c = \
../envSubr.c ../errSymLib.c \
../nextFieldSubr.c ../postfix.c \
../bucketLib.c ../memDebugLib.c ../tsSubr.c ../pal.c \
../paldef.c ../mprintf.c errSymTbl.c
../paldef.c errSymTbl.c ../errPrintfVX.c
OBJS = \
calcPerform.o cvtBpt.o cvtFast.o ellLib.o envSubr.o errSymLib.o \
errSymTbl.o nextFieldSubr.o postfix.o \
bucketLib.o tsSubr.o gpHashLib.o freeListLib.o pal.o paldef.o \
mprintf.o
errPrintfVX.o
PROD = libCom

View File

@@ -65,8 +65,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#ifdef _WINDOWS
# include <winsock.h>
#else
# include <sys/types.h>
# include <netinet/in.h>
#endif
#ifdef vxWorks
#include <inetLib.h>

View File

@@ -65,8 +65,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#ifdef _WINDOWS
# include <winsock.h>
#else
# include <sys/types.h>
# include <netinet/in.h>
#endif
#ifdef vxWorks
#include <inetLib.h>

View File

@@ -0,0 +1,79 @@
/* $Id$
* errPrintfUNIX.c
* Author: Marty Kraimer
* Date: 02-16-95
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1991, the Regents of the University of California,
* and the University of Chicago Board of Governors.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* and (W-31-109-ENG-38) at Argonne National Laboratory.
*
* Initial development by:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* Co-developed with
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
*
* Modification Log: errPrintfUNIX.c
* -----------------
* .01 02-16-95 mrk Extracted from errSymLib.c
***************************************************************************
* This must ultimately be replaced by a facility that allows remote
* nodes access to the error messages. A message handling communication
* task should be written that allows multiple remote nodes to request
* notification of all error messages.
* For now lets just print messages and last errno via logMsg or printf
***************************************************************************
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <dbDefs.h>
#include <errMdef.h>
#include "errSymTbl.h"
/****************************************************************
* ERRMESSAGE - now a macro to call errPrintf
* ERRPRINTF - print an error symbol message
***************************************************************/
void errPrintf(long status, const char *pFileName,
int lineno, const char *pformat, ...)
{
va_list pvar;
va_start(pvar, pformat);
if(pFileName && errVerbose){
printf("filename=\"%s\" line number=%d\n", pFileName, lineno);
}
if(status==0) status = errno;
if(status>0) {
int rtnval;
unsigned short modnum,errnum;
char name[256];
rtnval = errSymFind(status,name);
modnum = status >> 16;
errnum = status & 0xffff;
if(rtnval) {
printf( "Error status (module %hu, number %hu) not in symbol table",
modnum, errnum);
} else {
printf("%s ",name);
}
}
vprintf(pformat,pvar);
printf("\n");
}

264
src/libCom/errPrintfVX.c Normal file
View File

@@ -0,0 +1,264 @@
/* $Id$
* errPrintfVX.c
* Author: Marty Kraimer and Jeff Hill
* Date: 6-1-90
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1991, the Regents of the University of California,
* and the University of Chicago Board of Governors.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* and (W-31-109-ENG-38) at Argonne National Laboratory.
*
* Initial development by:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* Co-developed with
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
*
* Modification Log: errPrintfVX.c
* -----------------
* .01 02-16-95 mrk Extracted from errSymLib.c
***************************************************************************
*/
#include <stdio.h>
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <vxWorks.h>
#include <taskLib.h>
#include <errnoLib.h>
#include <intLib.h>
#include <types.h>
#include <symLib.h>
#include <semLib.h>
#include <error.h>
#include <logLib.h>
#include <ellLib.h>
#include <dbDefs.h>
#include <task_params.h>
#include <errMdef.h>
#include <epicsPrint.h>
#ifndef LOCAL
#define LOCAL static
#endif /* LOCAL */
static int mprintf (const char *pFormat, ...);
static int vmprintf (const char *pFormat, va_list pvar);
extern FILE *iocLogFile;
LOCAL SEM_ID clientWaitForTask;
LOCAL SEM_ID clientWaitForCompletion;
LOCAL SEM_ID serverWaitForWork;
LOCAL void epicsPrintTask(void);
LOCAL void errPrintfPVT(void);
typedef enum{cmdErrPrintf,cmdEpicsPrint} cmdType;
LOCAL struct {
cmdType cmd;
int taskid;
long status;
const char *pFileName;
int lineno;
const char *pformat;
va_list pvar;
int oldtaskid;
int printfStatus;
}pvtData;
void errInit(void)
{
pvtData.oldtaskid = 0;
if((clientWaitForTask=semBCreate(SEM_Q_FIFO,SEM_EMPTY))==NULL)
logMsg("semBcreate failed in errInit",0,0,0,0,0,0);
if((clientWaitForCompletion=semBCreate(SEM_Q_FIFO,SEM_EMPTY))==NULL)
logMsg("semBcreate failed in errInit",0,0,0,0,0,0);
if((serverWaitForWork=semBCreate(SEM_Q_FIFO,SEM_EMPTY))==NULL)
logMsg("semBcreate failed in errInit",0,0,0,0,0,0);
taskSpawn(EPICSPRINT_NAME,EPICSPRINT_PRI,EPICSPRINT_OPT,
EPICSPRINT_STACK,(FUNCPTR)epicsPrintTask,
0,0,0,0,0,0,0,0,0,0);
if ((errSymBld()) != 0) {
logMsg("errSymBld failed to initialize\n",0,0,0,0,0,0);
}
}
LOCAL void epicsPrintTask(void)
{
semGive(clientWaitForTask);
while(TRUE) {
if(semTake(serverWaitForWork,WAIT_FOREVER)!=OK)
logMsg("epicsPrint: semTake returned error\n",0,0,0,0,0,0);
switch(pvtData.cmd) {
case (cmdErrPrintf) :
errPrintfPVT();
break;
case (cmdEpicsPrint) :
pvtData.printfStatus = vmprintf(pvtData.pformat,pvtData.pvar);
break;
}
semGive(clientWaitForCompletion);
}
}
void errPrintf(long status, const char *pFileName,
int lineno, const char *pformat, ...)
{
va_list pvar;
if(INT_CONTEXT()) {
int logMsgArgs[6];
int i;
va_start (pvar, pformat);
for (i=0; i<NELEMENTS(logMsgArgs); i++) {
logMsgArgs[i] = va_arg(pvar, int);
}
logMsg ((char *)pformat,logMsgArgs[0],logMsgArgs[1],
logMsgArgs[2],logMsgArgs[3],logMsgArgs[4],
logMsgArgs[5]);
va_end (pvar);
return;
}
va_start (pvar, pformat);
if(semTake(clientWaitForTask,WAIT_FOREVER)!=OK) {
logMsg("epicsPrint: semTake returned error\n",0,0,0,0,0,0);
taskSuspend(taskIdSelf());
}
pvtData.cmd = cmdErrPrintf;
pvtData.taskid = taskIdSelf();
pvtData.status = status;
pvtData.pFileName = pFileName;
pvtData.lineno = lineno;
pvtData.pformat = pformat;
pvtData.pvar = pvar;
semGive(serverWaitForWork);
if(semTake(clientWaitForCompletion,WAIT_FOREVER)!=OK) {
logMsg("epicsPrint: semTake returned error\n",0,0,0,0,0,0);
taskSuspend(taskIdSelf());
}
semGive(clientWaitForTask);
}
LOCAL void errPrintfPVT(void)
{
long status = pvtData.status;
const char *pFileName = pvtData.pFileName;
int lineno = pvtData.lineno;
const char *pformat = pvtData.pformat;
va_list pvar = pvtData.pvar;
if(pvtData.taskid != pvtData.oldtaskid) {
mprintf("task: 0X%x %s\n",pvtData.taskid,taskName(pvtData.taskid));
pvtData.oldtaskid = pvtData.taskid;
}
if(pFileName && errVerbose){
mprintf("filename=\"%s\" line number=%d\n", pFileName, lineno);
}
if(status==0) status = MYERRNO;
if(status>0) {
int rtnval;
unsigned short modnum,errnum;
char name[256];
rtnval = errSymFind(status,name);
modnum = status >> 16;
errnum = status & 0xffff;
if(rtnval) {
mprintf("Error status (module %hu, number %hu) not in symbol table\n",
modnum, errnum);
} else {
mprintf("%s ",name);
}
}
vmprintf(pformat,pvar);
mprintf("\n");
return;
}
int epicsPrintf(const char *pformat, ...)
{
va_list pvar;
va_start(pvar, pformat);
return epicsVprintf(pformat,pvar);
}
int epicsVprintf(const char *pformat, va_list pvar)
{
int status;
if(INT_CONTEXT()) {
int logMsgArgs[6];
int i;
for (i=0; i<NELEMENTS(logMsgArgs); i++) {
logMsgArgs[i] = va_arg(pvar, int);
}
status = logMsg ((char *)pformat,logMsgArgs[0],logMsgArgs[1],
logMsgArgs[2],logMsgArgs[3],logMsgArgs[4],
logMsgArgs[5]);
va_end (pvar);
return status;
}
if(semTake(clientWaitForTask,WAIT_FOREVER)!=OK) {
logMsg("epicsPrint: semTake returned error\n",0,0,0,0,0,0);
taskSuspend(taskIdSelf());
}
pvtData.cmd = cmdEpicsPrint;
pvtData.pformat = pformat;
pvtData.pvar = pvar;
semGive(serverWaitForWork);
if(semTake(clientWaitForCompletion,WAIT_FOREVER)!=OK) {
logMsg("epicsPrint: semTake returned error\n",0,0,0,0,0,0);
taskSuspend(taskIdSelf());
}
status = pvtData.printfStatus;
semGive(clientWaitForTask);
return status;
}
LOCAL int mprintf (const char *pFormat, ...)
{
va_list pvar;
va_start (pvar, pFormat);
return vmprintf (pFormat, pvar);
}
LOCAL int vmprintf (const char *pFormat, va_list pvar)
{
int s0;
int s1;
s0 = vfprintf(stdout,pFormat,pvar);
fflush(stdout);
s1 = vfprintf(iocLogFile,pFormat,pvar);
fflush(iocLogFile);
va_end(pvar);
if (s1<0) {
return s1;
}
return s0;
}

View File

@@ -81,7 +81,6 @@
#include <symLib.h>
#include <errnoLib.h>
#include <mprintf.h>
extern SYMTAB_ID statSymTbl;
@@ -116,11 +115,6 @@ extern ERRSYMTAB_ID errSymTbl;
/*Declare storage for errVerbose( defined in errMdef.h)*/
int errVerbose=0;
#ifdef __STDC__
int verrPrintStatus(long status, char *pFormatString, va_list pvar);
#else
int verrPrintStatus();
#endif
/****************************************************************
@@ -197,161 +191,6 @@ unsigned short errnum;
return((unsigned short)(((modnum - 500) * 20) + errnum) % NHASH);
}
/****************************************************************
* ERRMESSAGE - now a macro to call errPrintf
* ERRPRINTF - print an error symbol message
***************************************************************/
#ifdef __STDC__
void errPrintf(long status, char *pFileName, int lineno, char *pformat, ...)
#else
void errPrintf(va_alist)
va_dcl
#endif
{
va_list pvar;
static char *pReformat;
static int reformatSize;
static char pAdd[] = {'\n', '\0'};
#ifndef __STDC__
long status;
char *pformat;
char *pFileName;
int lineno;
#endif
#ifdef __STDC__
va_start(pvar, pformat);
#else
va_start(pvar);
status = va_arg(pvar, long);
pFileName = va_arg(pvar, char *);
lineno = va_arg(pvar, int);
pformat = va_arg(pvar, char *);
#endif
if(pFileName && errVerbose){
mprintf("filename=\"%s\" line number=%d\n", pFileName, lineno);
}
if (pformat != NULL) {
int size;
size = strlen(pformat)+NELEMENTS(pAdd);
if(reformatSize < size){
/*
* use a reasonable size string
*/
size = max(0xff, size);
if(pReformat){
free(pReformat);
}
pReformat = (char *) malloc(size);
if(pReformat){
reformatSize = size;
}
else{
mprintf ("%s: calloc error\n", __FILE__);
return;
}
}
strcpy(pReformat, pformat);
strcat(pReformat, pAdd);
}
verrPrintStatus(status, pReformat, pvar);
return;
}
/****************************************************************
* ERRPRINTSTATUS
***************************************************************/
#ifdef __STDC__
int errPrintStatus(long status, char *pFormat, ...)
#else
int errPrintStatus(va_alist)
va_dcl
#endif
{
va_list pvar;
#ifndef __STDC__
long status;
char *pFormat;
#endif
#ifdef __STDC__
va_start(pvar, pFormat);
#else
va_start(pvar);
status = va_arg(pvar, long);
pFormat = va_arg(pvar, char *);
#endif
return verrPrintStatus(status, pFormat, pvar);
}
/****************************************************************
* VERRPRINTSTATUS
***************************************************************/
#ifdef __STDC__
int verrPrintStatus(long status, char *pFormatString, va_list pvar)
#else
int verrPrintStatus(status, pFormatString, pvar)
long status;
char *pFormatString;
va_list pvar;
#endif
{
static char ctxToLarge[] = "** Context String Overflow **";
char name[256];
int rtnval;
int namelen;
int formatlen;
unsigned short modnum;
unsigned short errnum;
name[0] = '\0';
if(status==0) status = MYERRNO;
if(status >= -1){
rtnval = 0;
}
else {
rtnval = status;
}
if(status>0) {
rtnval = errSymFind(status,name);
modnum = status >> 16;
errnum = status & 0xffff;
if(rtnval) {
sprintf(name,
"Error status (module %hu, number %hu) not in symbol table",
modnum, errnum);
}
}
if(pFormatString){
namelen = strlen(name);
formatlen = strlen(pFormatString);
strcat(name," ");
if(sizeof(name)-namelen-1 > formatlen){
strcat(name, pFormatString);
}
else if(sizeof(name)-namelen-1 > sizeof(ctxToLarge)){
strcat(name, ctxToLarge);
}
else{
mprintf(ctxToLarge);
}
}
vmprintf(name, pvar);
return rtnval;
}
/****************************************************************
* ERRSYMBOLADD
* adds symbols to the master errnumlist as compiled from errSymTbl.c

View File

@@ -81,7 +81,6 @@
#include <symLib.h>
#include <errnoLib.h>
#include <mprintf.h>
extern SYMTAB_ID statSymTbl;
@@ -116,11 +115,6 @@ extern ERRSYMTAB_ID errSymTbl;
/*Declare storage for errVerbose( defined in errMdef.h)*/
int errVerbose=0;
#ifdef __STDC__
int verrPrintStatus(long status, char *pFormatString, va_list pvar);
#else
int verrPrintStatus();
#endif
/****************************************************************
@@ -197,161 +191,6 @@ unsigned short errnum;
return((unsigned short)(((modnum - 500) * 20) + errnum) % NHASH);
}
/****************************************************************
* ERRMESSAGE - now a macro to call errPrintf
* ERRPRINTF - print an error symbol message
***************************************************************/
#ifdef __STDC__
void errPrintf(long status, char *pFileName, int lineno, char *pformat, ...)
#else
void errPrintf(va_alist)
va_dcl
#endif
{
va_list pvar;
static char *pReformat;
static int reformatSize;
static char pAdd[] = {'\n', '\0'};
#ifndef __STDC__
long status;
char *pformat;
char *pFileName;
int lineno;
#endif
#ifdef __STDC__
va_start(pvar, pformat);
#else
va_start(pvar);
status = va_arg(pvar, long);
pFileName = va_arg(pvar, char *);
lineno = va_arg(pvar, int);
pformat = va_arg(pvar, char *);
#endif
if(pFileName && errVerbose){
mprintf("filename=\"%s\" line number=%d\n", pFileName, lineno);
}
if (pformat != NULL) {
int size;
size = strlen(pformat)+NELEMENTS(pAdd);
if(reformatSize < size){
/*
* use a reasonable size string
*/
size = max(0xff, size);
if(pReformat){
free(pReformat);
}
pReformat = (char *) malloc(size);
if(pReformat){
reformatSize = size;
}
else{
mprintf ("%s: calloc error\n", __FILE__);
return;
}
}
strcpy(pReformat, pformat);
strcat(pReformat, pAdd);
}
verrPrintStatus(status, pReformat, pvar);
return;
}
/****************************************************************
* ERRPRINTSTATUS
***************************************************************/
#ifdef __STDC__
int errPrintStatus(long status, char *pFormat, ...)
#else
int errPrintStatus(va_alist)
va_dcl
#endif
{
va_list pvar;
#ifndef __STDC__
long status;
char *pFormat;
#endif
#ifdef __STDC__
va_start(pvar, pFormat);
#else
va_start(pvar);
status = va_arg(pvar, long);
pFormat = va_arg(pvar, char *);
#endif
return verrPrintStatus(status, pFormat, pvar);
}
/****************************************************************
* VERRPRINTSTATUS
***************************************************************/
#ifdef __STDC__
int verrPrintStatus(long status, char *pFormatString, va_list pvar)
#else
int verrPrintStatus(status, pFormatString, pvar)
long status;
char *pFormatString;
va_list pvar;
#endif
{
static char ctxToLarge[] = "** Context String Overflow **";
char name[256];
int rtnval;
int namelen;
int formatlen;
unsigned short modnum;
unsigned short errnum;
name[0] = '\0';
if(status==0) status = MYERRNO;
if(status >= -1){
rtnval = 0;
}
else {
rtnval = status;
}
if(status>0) {
rtnval = errSymFind(status,name);
modnum = status >> 16;
errnum = status & 0xffff;
if(rtnval) {
sprintf(name,
"Error status (module %hu, number %hu) not in symbol table",
modnum, errnum);
}
}
if(pFormatString){
namelen = strlen(name);
formatlen = strlen(pFormatString);
strcat(name," ");
if(sizeof(name)-namelen-1 > formatlen){
strcat(name, pFormatString);
}
else if(sizeof(name)-namelen-1 > sizeof(ctxToLarge)){
strcat(name, ctxToLarge);
}
else{
mprintf(ctxToLarge);
}
}
vmprintf(name, pvar);
return rtnval;
}
/****************************************************************
* ERRSYMBOLADD
* adds symbols to the master errnumlist as compiled from errSymTbl.c

138
src/libCom/sun4ansi.c Normal file
View File

@@ -0,0 +1,138 @@
#ifdef SUNOS4
/*
* $Log$
* Revision 1.1 1995/01/11 10:34:21 anj
* Added sun4ansi.c for those without sun4 ACC.
*
*
*
* Routines which are needed but SunOS 4.x doesn't provide.
* These definitions obtained from GNU libiberty directory.
* Note that Sun's Ansi C compiler provides these routines,
* so there ought to be a way of excluding this file if you
* have that...
*
*/
/*
* strtol : convert a string to long.
*
* Andy Wilson, 2-Oct-89.
*/
#include <errno.h>
#include <ctype.h>
#include <stdio.h>
#include <limits.h>
extern int errno;
extern int sys_nerr;
extern char *sys_errlist[];
unsigned long
strtoul(const char *s, char **ptr, int base)
{
unsigned long total = 0, tmp = 0;
unsigned digit;
const char *start=s;
int did_conversion=0;
int negate = 0;
if (s==NULL)
{
errno = ERANGE;
if (!ptr)
*ptr = (char *)start;
return 0L;
}
while (isspace(*s))
s++;
if (*s == '+')
s++;
else if (*s == '-')
s++, negate = 1;
if (base==0 || base==16) /* the 'base==16' is for handling 0x */
{
/*
* try to infer base from the string
*/
if (*s != '0')
tmp = 10; /* doesn't start with 0 - assume decimal */
else if (s[1] == 'X' || s[1] == 'x')
tmp = 16, s += 2; /* starts with 0x or 0X - hence hex */
else
tmp = 8; /* starts with 0 - hence octal */
if (base==0)
base = (int)tmp;
}
while ( digit = *s )
{
if (digit >= '0' && digit < ('0'+base))
digit -= '0';
else
if (base > 10)
{
if (digit >= 'a' && digit < ('a'+(base-10)))
digit = digit - 'a' + 10;
else if (digit >= 'A' && digit < ('A'+(base-10)))
digit = digit - 'A' + 10;
else
break;
}
else
break;
did_conversion = 1;
tmp = (total * base) + digit;
if (tmp < total) /* check overflow */
{
errno = ERANGE;
if (ptr != NULL)
*ptr = (char *)s;
return (ULONG_MAX);
}
total = tmp;
s++;
}
if (ptr != NULL)
*ptr = (char *) ((did_conversion) ? (char *)s : (char *)start);
return negate ? -total : total;
}
/*
* strerror
*
* convert an error number into a string
*/
char *
strerror (errnoval)
int errnoval;
{
char *msg;
static char buf[32];
if ((errnoval < 0) || (errnoval >= sys_nerr))
{
/* Out of range, just return NULL */
msg = NULL;
}
else if ((sys_errlist == NULL) || (sys_errlist[errnoval] == NULL))
{
/* In range, but no sys_errlist or no entry at this index. */
sprintf (buf, "Error %d", errnoval);
msg = buf;
}
else
{
/* In range, and a valid message. Just return the message. */
msg = sys_errlist[errnoval];
}
return (msg);
}
#endif

View File

@@ -42,7 +42,7 @@ SRCS.c = \
../recTimer.c\
../recWaveform.c\
../recWait.c\
../caMonitor.c
../recWaitCa.c
# ../recPal.c\
# ../recSwitch.c\
# ../recGsub.c\
@@ -89,7 +89,7 @@ OBJS = \
recDfanout.o\
recMbbiDirect.o\
recMbboDirect.o\
caMonitor.o
recWaitCa.o
# recPal.o\
# recSwitch.o\
# recGsub.o\

View File

@@ -39,11 +39,13 @@
* .06 08-19-94 nda added Output data option of VAL or DOL
* .07 09-14-94 nda corrected bug that caused SCAN_DISABLE to lock up the record forever
* .08 02-01-95 nda added VERS and ODLY (output execution delay)
* .09 02-15-95 nda addedd INxP to determine which inputs should cause the record
* to process when in I/O INTR mode.
*
*
*/
#define VERSION 1.08
#define VERSION 1.09
@@ -74,7 +76,7 @@
#include <choiceWait.h>
#include <waitRecord.h>
#include <caMonitor.h>
#include <recWaitCa.h>
/* Create RSET - Record Support Entry Table*/
@@ -162,7 +164,7 @@ struct cbStruct {
struct waitRecord *pwait; /* pointer to wait record which needs work done */
WDOG_ID wd_id; /* Watchdog used for delays */
IOSCANPVT ioscanpvt; /* used for IO_EVENT scanning */
CAMONITOR inpMonitor[12]; /* required structures for each input variable */
RECWAITCA inpMonitor[12]; /* required structures for each input variable */
int procPending; /* flag to indicate record processing is pending */
};
@@ -185,9 +187,10 @@ static long init_record(pwait,pass)
long status = 0;
int i;
char *ppvn[PVN_SIZE];
struct dbAddr **ppdbAddr; /* ptr to a ptr to dbAddr */
long *paddrValid;
char *ppvn[PVN_SIZE];
struct dbAddr **ppdbAddr; /* ptr to a ptr to dbAddr */
long *paddrValid;
unsigned short *piointInc; /* include for IO_INT ? */
char rpbuf[184];
short error_number;
@@ -258,12 +261,14 @@ static long init_record(pwait,pass)
/* MON_ALWAYS if(pwait->scan == SCAN_IO_EVENT) { */
if(1) {
paddrValid = &pwait->inav;
piointInc = &pwait->inap;
for(i=0;i<ARG_MAX; i++, paddrValid++) {
if(!(*paddrValid)) {
if(waitRecDebug) printf("adding monitor\n");
status = caMonitorAdd(&(((struct cbStruct *)pwait->cbst)->inpMonitor[i]));
if(status) errMessage(status,"caMonitorAdd error");
for(i=0;i<ARG_MAX; i++, paddrValid++, piointInc++) {
/* if valid PV AND input include flag is true ... */
if(!(*paddrValid) && (*piointInc)) {
if(waitRecDebug) printf("adding monitor on input %d\n", i);
status = recWaitCaAdd(&(((struct cbStruct *)pwait->cbst)->inpMonitor[i]));
if(status) errMessage(status,"recWaitCaAdd error");
}
}
}
@@ -372,43 +377,43 @@ static long special(paddr,after)
char *ppvn[PVN_SIZE];
struct dbAddr **ppdbAddr; /* ptr to a ptr to dbAddr */
long *paddrValid;
unsigned short *piointInc; /* include for IO_INT ? */
int i;
long status;
long odbv =0;
short error_number;
char rpbuf[184];
if(waitRecDebug) printf("entering special \n");
if(!after) { /* this is called before ca changes the field */
switch(special_type) {
case(SPC_SCAN): /* about to change SCAN mechanism ... */
if(pwait->scan == SCAN_IO_EVENT) {
/* Leaving IO_EVENT, delete monitors */
paddrValid = &pwait->inav;
for(i=0;i<ARG_MAX; i++, paddrValid++) {
if(!(*paddrValid)) {
if(waitRecDebug) printf("deleting monitor\n");
status = caMonitorDelete(&(((struct cbStruct *)pwait->cbst)->inpMonitor[i]));
if(status) errMessage(status,"caMonitorDelete error");
}
}
}
break;
if(waitRecDebug) printf("entering special %d \n",after);
case(SPC_MOD): /* check if changing any PV names while monitored */
/* MON_ALWAYS if(pwait->scan == SCAN_IO_EVENT) { */
if(1) {
*ppvn = &pwait->inan[0];
paddrValid = &pwait->inav;
for(i=0;i<ARG_MAX; i++, *ppvn += PVN_SIZE, paddrValid++) {
if((paddr->pfield==*ppvn) && !(*paddrValid)) {
if(waitRecDebug) printf("deleting monitor\n");
status = caMonitorDelete(&(((struct cbStruct *)pwait->cbst)->inpMonitor[i]));
if(status) errMessage(status,"caMonitorDelete error");
}
}
}
break;
if(!after) { /* this is called before ca changes the field */
/* MON_ALWAYS This case doesn't currently happen */
if((special_type == SPC_SCAN) && (pwait->scan == SCAN_IO_EVENT)) {
/* Leaving IO_EVENT, delete monitors */
paddrValid = &pwait->inav;
for(i=0;i<ARG_MAX; i++, paddrValid++) {
if(!(*paddrValid)) {
if(waitRecDebug) printf("deleting monitor\n");
status = recWaitCaDelete(&(((struct cbStruct *)pwait->cbst)->inpMonitor[i]));
if(status) errMessage(status,"recWaitCaDelete error");
}
}
return(0);
}
/* check if changing any Input PV names/flags while monitored */
if((special_type >= REC_WAIT_A) && (special_type <= REC_WAIT_L)) {
/* MON_ALWAYS if(pwait->scan == SCAN_IO_EVENT) */
/* About to change a PV or flag, delete that particular monitor */
i = special_type - REC_WAIT_A; /* index of input */
paddrValid = &pwait->inav + i; /* pointer arithmetic */
piointInc = &pwait->inap + i; /* pointer arithmetic */
/* If PV name is valid and the INxP flag is true, ... */
if(!(*paddrValid) && (*piointInc)) {
if(waitRecDebug) printf("deleting monitor on input %d\n",i);
status = recWaitCaDelete(&(((struct cbStruct *)pwait->cbst)->inpMonitor[i]));
if(status) errMessage(status,"recWaitCaDelete error");
}
}
return(0);
}
@@ -416,38 +421,58 @@ static long special(paddr,after)
/* this is executed after ca changed the field */
switch(special_type) {
case(SPC_SCAN): /* Changed SCAN mechanism, set monitors on input links */
/* MON_ALWAYS This case currently doesn't happen */
if(pwait->scan == SCAN_IO_EVENT) {
paddrValid = &pwait->inav;
for(i=0;i<ARG_MAX; i++, paddrValid++) {
if(!(*paddrValid)) {
if(waitRecDebug) printf("adding monitor\n");
status = caMonitorAdd(&(((struct cbStruct *)pwait->cbst)->inpMonitor[i]));
if(status) errMessage(status,"caMonitorAdd error");
if(waitRecDebug) printf("adding monitor on input %d\n", i);
status = recWaitCaAdd(&(((struct cbStruct *)pwait->cbst)->inpMonitor[i]));
if(status) errMessage(status,"recWaitCaAdd error");
}
}
}
return(0);
case(SPC_MOD): /* check if changing any PV names */
*ppvn = &pwait->inan[0];
ppdbAddr = (struct dbAddr **)&pwait->inaa;
paddrValid = &pwait->inav;
break;
case(REC_WAIT_A): /* check if changing any input PV's or flags */
case(REC_WAIT_B):
case(REC_WAIT_C):
case(REC_WAIT_D):
case(REC_WAIT_E):
case(REC_WAIT_F):
case(REC_WAIT_G):
case(REC_WAIT_H):
case(REC_WAIT_I):
case(REC_WAIT_J):
case(REC_WAIT_K):
case(REC_WAIT_L):
i = special_type - REC_WAIT_A; /* index of input */
paddrValid = &pwait->inav + i; /* pointer arithmetic */
ppdbAddr = (struct dbAddr **)&pwait->inaa + i; /* pointer arithmetic */
*ppvn = &pwait->inan[0] + (i*PVN_SIZE);
for(i=0;i<ARG_MAX; i++, *ppvn += PVN_SIZE, ppdbAddr++, paddrValid++) {
if(paddr->pfield==*ppvn) {
odbv = *paddrValid;
*paddrValid = dbNameToAddr(*ppvn, *ppdbAddr);
if (odbv != *paddrValid) {
db_post_events(pwait,paddrValid,DBE_VALUE);
}
/* MON_ALWAYS if((pwait->scan == SCAN_IO_EVENT) && !(*paddrValid)) { */
if((1) && !(*paddrValid)) {
if(waitRecDebug) printf("adding monitor\n");
status = caMonitorAdd(&(((struct cbStruct *)pwait->cbst)->inpMonitor[i]));
if(status) errMessage(status,"caMonitorAdd error");
}
return(0);
}
}
/* If the PV Name changing, do dbNameToAddr */
if(paddr->pfield==*ppvn) {
odbv = *paddrValid;
*paddrValid = dbNameToAddr(*ppvn, *ppdbAddr);
if (odbv != *paddrValid) {
db_post_events(pwait,paddrValid,DBE_VALUE);
}
}
/* MON_ALWAYS: Should only do if SCAN_IO_EVENT), but can't now */
/* If the INxP flag is set, add a monitor */
piointInc = &pwait->inap + i; /* pointer arithmetic */
if(!(*paddrValid) && (*piointInc)) {
if(waitRecDebug) printf("adding monitor on input %d\n", i);
status = recWaitCaAdd(&(((struct cbStruct *)pwait->cbst)->inpMonitor[i]));
if(status) errMessage(status,"recWaitCaAdd error");
}
return(0);
break;
case(SPC_MOD): /* check if changing any other SPC_MOD fields */
if(paddr->pfield==pwait->outn) { /* this is the output link */
odbv = pwait->outv;
pwait->outv = dbNameToAddr(pwait->outn,(struct dbAddr *)pwait->outa);
@@ -467,6 +492,7 @@ static long special(paddr,after)
}
return(0);
break;
case(SPC_CALC):
pwait->clcv=postfix(pwait->calc,rpbuf,&error_number);
@@ -481,6 +507,7 @@ static long special(paddr,after)
db_post_events(pwait,pwait->calc,DBE_VALUE);
db_post_events(pwait,pwait->clcv,DBE_VALUE);
return(0);
break;
default:
recGblDbaddrError(S_db_badChoice,paddr,"wait: special");
return(S_db_badChoice);
@@ -725,7 +752,7 @@ static double oldDold;
static void inputChanged(struct caMonitor *pcamonitor)
static void inputChanged(struct recWaitCa *pcamonitor)
{
struct waitRecord *pwait = (struct waitRecord *)pcamonitor->userPvt;

154
src/rec/recWaitCa.c Normal file
View File

@@ -0,0 +1,154 @@
#include <vxWorks.h>
#include <taskLib.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include <rngLib.h>
#include <ellLib.h>
#include <vxLib.h>
#include <dbDefs.h>
#include <taskwd.h>
#include <fast_lock.h>
#include <cadef.h>
#include <caerr.h>
#include <caeventmask.h>
#include <calink.h>
#include <task_params.h>
#include <freeList.h>
#include <recWaitCa.h>
extern int interruptAccept;
#define QUEUE_SIZE 256
LOCAL int taskid=0;
LOCAL ELLLIST capvtList;
LOCAL RING_ID ringQ;;
LOCAL FAST_LOCK lock;
LOCAL void *freeListPvt;
typedef enum {cmdNone,cmdAdd,cmdRemove} COMMAND;
typedef struct {
ELLNODE node;
RECWAITCA *pcamonitor;
chid chid;
evid evid;
COMMAND cmd;
struct dbr_sts_double rtndata; /*Not currently used */
} CAPVT;
void recWaitCaTask(void);
LOCAL void eventCallback(struct event_handler_args eha)
{
struct dbr_sts_double *pdata = eha.dbr;
CAPVT *pcapvt;
RECWAITCA *pcamonitor;
pcapvt = (CAPVT *)eha.usr;
pcamonitor = pcapvt->pcamonitor;
(pcamonitor->callback)(pcamonitor);
}
LOCAL void recWaitCaStart(void)
{
FASTLOCKINIT(&lock);
freeListInitPvt(&freeListPvt,sizeof(CAPVT),1);
if((ringQ = rngCreate(sizeof(void *) * QUEUE_SIZE)) == NULL) {
errMessage(0,"recWaitCaStart failed");
exit(1);
}
ellInit(&capvtList);
taskid = taskSpawn("recWaitCaTask",CA_CLIENT_PRI-1,VX_FP_TASK,
CA_CLIENT_STACK,(FUNCPTR)recWaitCaTask,0,0,0,0,0,0,0,0,0,0);
if(taskid==ERROR) {
errMessage(0,"recWaitCaStart: taskSpawn Failure\n");
}
}
long recWaitCaAdd(RECWAITCA *pcamonitor)
{
CAPVT *pcapvt;
if(!taskid) recWaitCaStart();
FASTLOCK(&lock);
pcapvt = freeListCalloc(freeListPvt);
pcamonitor->recWaitCaPvt = pcapvt;
pcapvt->pcamonitor = pcamonitor;
pcapvt->cmd = cmdAdd;
if(rngBufPut(ringQ,(void *)&pcapvt,sizeof(pcapvt))
!=sizeof(pcamonitor)) errMessage(0,"recWaitCaAdd: rngBufPut error");
ellAdd(&capvtList,(void *)pcapvt);
FASTUNLOCK(&lock);
}
long recWaitCaDelete(RECWAITCA *pcamonitor)
{
CAPVT *pcapvt = pcamonitor->recWaitCaPvt;
FASTLOCK(&lock);
pcapvt->cmd = cmdRemove;
if(rngBufPut(ringQ,(void *)&pcapvt,sizeof(pcapvt))
!=sizeof(pcamonitor)) errMessage(0,"recWaitCaDelete: rngBufPut error");
FASTUNLOCK(&lock);
}
/*LOCAL */
void recWaitCaTask(void)
{
CAPVT *pcapvt;
RECWAITCA *pcamonitor;
int status;
taskwdInsert(taskIdSelf(),NULL,NULL);
SEVCHK(ca_task_initialize(),"ca_task_initialize");
while(TRUE) {
while (rngNBytes(ringQ)>=sizeof(pcapvt) && interruptAccept){
if(rngBufGet(ringQ,(void *)&pcapvt,sizeof(pcapvt))
!=sizeof(pcapvt)) {
errMessage(0,"recWaitCaTask: rngBufGet error");
continue;
}
FASTLOCK(&lock);
pcamonitor = pcapvt->pcamonitor;
if(pcapvt->cmd==cmdAdd) {
SEVCHK(ca_build_and_connect(pcamonitor->channame,TYPENOTCONN,0,
&pcapvt->chid,0,NULL,pcapvt),
"ca_build_and_connect");
SEVCHK(ca_add_event(DBR_STS_DOUBLE,pcapvt->chid,
eventCallback,pcapvt,&pcapvt->evid),
"ca_add_event");
} else {/*must be cmdRemove*/
SEVCHK(ca_clear_channel(pcapvt->chid),"ca_clear_channel");
pcapvt->cmd=cmdNone;
ellDelete(&capvtList,(void *)pcapvt);
freeListFree(freeListPvt,pcapvt);
}
pcapvt->cmd=cmdNone;
FASTUNLOCK(&lock);
}
status = ca_pend_event(.1);
if(status!=ECA_NORMAL && status!=ECA_TIMEOUT)
SEVCHK(status,"ca_pend_event");
}
}
static void myCallback(struct recWaitCa *pcamonitor)
{
printf("myCallback: %s\n",pcamonitor->channame);
}
int testCaMonitor(char *name)
{
RECWAITCA *pcamonitor;
long status;
pcamonitor = calloc(1,sizeof(RECWAITCA));
pcamonitor->channame = calloc(1,strlen(name)+1);
pcamonitor->callback = myCallback;
strcpy(pcamonitor->channame,name);
status = recWaitCaAdd(pcamonitor);
if(status) errMessage(status,"testCaMonitor error");
return(0);
}

9
src/rec/recWaitCa.h Normal file
View File

@@ -0,0 +1,9 @@
typedef struct recWaitCa{
char *channame;
void (*callback)(struct recWaitCa *pcamonitor);
void *userPvt;
void *recWaitCaPvt;
} RECWAITCA;
long recWaitCaAdd(RECWAITCA *pcamonitor);
long recWaitCaDelete(RECWAITCA *pcamonitor);

View File

@@ -65,8 +65,8 @@ LOCAL int ca_test(char *pname, char *pvalue);
LOCAL int cagft(char *pname);
LOCAL void printit(struct event_handler_args args);
LOCAL int capft(char *pname, char *pvalue);
LOCAL void verify(chid chan_id, int type);
LOCAL void print_returned(short type, char *pbuffer, short count);
LOCAL void verify_value(chid chan_id, chtype type);
LOCAL void print_returned(chtype type, void *pbuffer, unsigned count);
static long outstanding;
@@ -280,7 +280,7 @@ char *pvalue
chan_id,
pvalue);
SEVCHK(status, NULL);
verify(chan_id, DBR_STRING);
verify_value(chan_id, DBR_STRING);
if(ca_field_type(chan_id)==0)goto skip_rest;
@@ -293,20 +293,20 @@ char *pvalue
chan_id,
&shortvalue);
SEVCHK(status, NULL);
verify(chan_id, DBR_SHORT);
verify_value(chan_id, DBR_SHORT);
status = ca_put(
DBR_ENUM,
chan_id,
&shortvalue);
SEVCHK(status, NULL);
verify(chan_id, DBR_ENUM);
verify_value(chan_id, DBR_ENUM);
charvalue=shortvalue;
status = ca_put(
DBR_CHAR,
chan_id,
&charvalue);
SEVCHK(status, NULL);
verify(chan_id, DBR_CHAR);
verify_value(chan_id, DBR_CHAR);
}
if(sscanf(pvalue,"%ld",&longvalue)==1) {
/*
@@ -317,7 +317,7 @@ char *pvalue
chan_id,
&longvalue);
SEVCHK(status, NULL);
verify(chan_id, DBR_LONG);
verify_value(chan_id, DBR_LONG);
}
if(sscanf(pvalue,"%f",&floatvalue)==1) {
/*
@@ -328,7 +328,7 @@ char *pvalue
chan_id,
&floatvalue);
SEVCHK(status, NULL);
verify(chan_id, DBR_FLOAT);
verify_value(chan_id, DBR_FLOAT);
}
if(sscanf(pvalue,"%lf",&doublevalue)==1) {
/*
@@ -339,7 +339,7 @@ char *pvalue
chan_id,
&doublevalue);
SEVCHK(status, NULL);
verify(chan_id, DBR_DOUBLE);
verify_value(chan_id, DBR_DOUBLE);
}
skip_rest:
@@ -364,11 +364,11 @@ skip_rest:
/*
* VERIFY
* VERIFY_VALUE
*
* initiate print out the values in a database access interface structure
*/
LOCAL void verify(chid chan_id, int type)
LOCAL void verify_value(chid chan_id, chtype type)
{
int status;
@@ -395,22 +395,26 @@ LOCAL void verify(chid chan_id, int type)
*
* switches over the range of CA data types and reports the value
*/
LOCAL void print_returned(short type, char *pbuffer, short count)
LOCAL void print_returned(chtype type, void *pbuffer, unsigned count)
{
short i;
unsigned i;
printf("%s\t",dbr_text[type]);
switch(type){
case (DBR_STRING):
for(i=0; i<count && *pbuffer!=0; i++) {
{
dbr_string_t *pString = (dbr_string_t *) pbuffer;
for(i=0; i<count && (*pString)[0]!='\0'; i++) {
if(count!=1 && (i%5 == 0)) printf("\n");
printf("%s ",pbuffer);
pbuffer += MAX_STRING_SIZE;
printf("%s ", *pString);
pString++;
}
break;
}
case (DBR_SHORT):
{
short *pvalue = (short *)pbuffer;
dbr_short_t *pvalue = (dbr_short_t *)pbuffer;
for (i = 0; i < count; i++,pvalue++){
if(count!=1 && (i%10 == 0)) printf("\n");
printf("%d ",*(short *)pvalue);
@@ -419,7 +423,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
}
case (DBR_ENUM):
{
unsigned short *pvalue = (unsigned short *)pbuffer;
dbr_enum_t *pvalue = (dbr_enum_t *)pbuffer;
for (i = 0; i < count; i++,pvalue++){
if(count!=1 && (i%10 == 0)) printf("\n");
printf("%d ",*pvalue);
@@ -428,7 +432,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
}
case (DBR_FLOAT):
{
float *pvalue = (float *)pbuffer;
dbr_float_t *pvalue = (dbr_float_t *)pbuffer;
for (i = 0; i < count; i++,pvalue++){
if(count!=1 && (i%10 == 0)) printf("\n");
printf("%6.4f ",*(float *)pvalue);
@@ -437,18 +441,17 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
}
case (DBR_CHAR):
{
int value;
dbr_char_t *pvalue = (dbr_char_t *) pbuffer;
for (i = 0; i < count; i++,pbuffer++){
for (i = 0; i < count; i++,pvalue++){
if(count!=1 && (i%10 == 0)) printf("\n");
value = *(unsigned char *)pbuffer;
printf("%d ",value);
printf("%u ",*pvalue);
}
break;
}
case (DBR_LONG):
{
long *pvalue = (long *)pbuffer;
dbr_long_t *pvalue = (dbr_long_t *)pbuffer;
for (i = 0; i < count; i++,pvalue++){
if(count!=1 && (i%10 == 0)) printf("\n");
printf("0x%x ",*pvalue);
@@ -457,7 +460,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
}
case (DBR_DOUBLE):
{
double *pvalue = (double *)pbuffer;
dbr_double_t *pvalue = (dbr_double_t *)pbuffer;
for (i = 0; i < count; i++,pvalue++){
if(count!=1 && (i%10 == 0)) printf("\n");
printf("%6.4f ",(float)(*pvalue));
@@ -478,12 +481,12 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_sts_enum *pvalue
= (struct dbr_sts_enum *)pbuffer;
unsigned short *pshort = &pvalue->value;
dbr_enum_t *pEnum = &pvalue->value;
printf("%2d %2d",pvalue->status,pvalue->severity);
if(count==1) printf("\tValue: ");
for (i = 0; i < count; i++,pshort++){
for (i = 0; i < count; i++,pEnum++){
if(count!=1 && (i%10 == 0)) printf("\n");
printf("%d ",*pshort);
printf("%u ",*pEnum);
}
break;
}
@@ -491,12 +494,12 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_sts_short *pvalue
= (struct dbr_sts_short *)pbuffer;
short *pshort = &pvalue->value;
dbr_short_t *pshort = &pvalue->value;
printf("%2d %2d",pvalue->status,pvalue->severity);
if(count==1) printf("\tValue: ");
for (i = 0; i < count; i++,pshort++){
if(count!=1 && (i%10 == 0)) printf("\n");
printf("%d ",*pshort);
printf("%u ",*pshort);
}
break;
}
@@ -504,7 +507,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_sts_float *pvalue
= (struct dbr_sts_float *)pbuffer;
float *pfloat = &pvalue->value;
dbr_float_t *pfloat = &pvalue->value;
printf("%2d %2d",pvalue->status,pvalue->severity);
if(count==1) printf("\tValue: ");
for (i = 0; i < count; i++,pfloat++){
@@ -517,15 +520,13 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_sts_char *pvalue
= (struct dbr_sts_char *)pbuffer;
unsigned char *pchar = &pvalue->value;
short value;
dbr_char_t *pchar = &pvalue->value;
printf("%2d %2d",pvalue->status,pvalue->severity);
if(count==1) printf("\tValue: ");
for (i = 0; i < count; i++,pchar++){
if(count!=1 && (i%10 == 0)) printf("\n");
value=*pchar;
printf("%d ",value);
printf("%u ", *pchar);
}
break;
}
@@ -546,7 +547,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_sts_double *pvalue
= (struct dbr_sts_double *)pbuffer;
double *pdouble = &pvalue->value;
dbr_double_t *pdouble = &pvalue->value;
printf("%2d %2d",pvalue->status,pvalue->severity);
if(count==1) printf("\tValue: ");
for (i = 0; i < count; i++,pdouble++){
@@ -570,7 +571,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_time_enum *pvalue
= (struct dbr_time_enum *)pbuffer;
unsigned short *pshort = &pvalue->value;
dbr_enum_t *pshort = &pvalue->value;
printf("%2d %2d",pvalue->status,pvalue->severity);
printf("\tTimeStamp: %lx %lx",
pvalue->stamp.secPastEpoch, pvalue->stamp.nsec);
@@ -585,7 +586,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_time_short *pvalue
= (struct dbr_time_short *)pbuffer;
short *pshort = &pvalue->value;
dbr_short_t *pshort = &pvalue->value;
printf("%2d %2d",pvalue->status,pvalue->severity);
printf("\tTimeStamp: %lx %lx",
pvalue->stamp.secPastEpoch, pvalue->stamp.nsec);
@@ -600,7 +601,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_time_float *pvalue
= (struct dbr_time_float *)pbuffer;
float *pfloat = &pvalue->value;
dbr_float_t *pfloat = &pvalue->value;
printf("%2d %2d",pvalue->status,pvalue->severity);
printf("\tTimeStamp: %lx %lx",
pvalue->stamp.secPastEpoch, pvalue->stamp.nsec);
@@ -615,7 +616,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_time_char *pvalue
= (struct dbr_time_char *)pbuffer;
unsigned char *pchar = &pvalue->value;
dbr_char_t *pchar = &pvalue->value;
printf("%2d %2d",pvalue->status,pvalue->severity);
printf("\tTimeStamp: %lx %lx",
pvalue->stamp.secPastEpoch, pvalue->stamp.nsec);
@@ -645,7 +646,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_time_double *pvalue
= (struct dbr_time_double *)pbuffer;
double *pdouble = &pvalue->value;
dbr_double_t *pdouble = &pvalue->value;
printf("%2d %2d",pvalue->status,pvalue->severity);
printf("\tTimeStamp: %lx %lx",
pvalue->stamp.secPastEpoch, pvalue->stamp.nsec);
@@ -660,7 +661,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_gr_short *pvalue
= (struct dbr_gr_short *)pbuffer;
short *pshort = &pvalue->value;
dbr_short_t *pshort = &pvalue->value;
printf("%2d %2d %.8s",pvalue->status,pvalue->severity,
pvalue->units);
printf("\n\t%8d %8d %8d %8d %8d %8d",
@@ -678,7 +679,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_gr_float *pvalue
= (struct dbr_gr_float *)pbuffer;
float *pfloat = &pvalue->value;
dbr_float_t *pfloat = &pvalue->value;
printf("%2d %2d %.8s",pvalue->status,pvalue->severity,
pvalue->units);
printf(" %3d\n\t%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f",
@@ -712,7 +713,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_gr_char *pvalue
= (struct dbr_gr_char *)pbuffer;
unsigned char *pchar = &pvalue->value;
dbr_char_t *pchar = &pvalue->value;
printf("%2d %2d %.8s",pvalue->status,pvalue->severity,
pvalue->units);
printf("\n\t%8d %8d %8d %8d %8d %8d",
@@ -722,7 +723,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
if(count==1) printf("\tValue: ");
for (i = 0; i < count; i++,pchar++){
if(count!=1 && (i%10 == 0)) printf("\n");
printf("%d ",(short)(*pchar));
printf("%u ",*pchar);
}
break;
}
@@ -748,7 +749,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_gr_double *pvalue
= (struct dbr_gr_double *)pbuffer;
double *pdouble = &pvalue->value;
dbr_double_t *pdouble = &pvalue->value;
printf("%2d %2d %.8s",pvalue->status,pvalue->severity,
pvalue->units);
printf(" %3d\n\t%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f",
@@ -770,7 +771,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_ctrl_short *pvalue
= (struct dbr_ctrl_short *)pbuffer;
short *pshort = &pvalue->value;
dbr_short_t *pshort = &pvalue->value;
printf("%2d %2d %.8s",pvalue->status,pvalue->severity,
pvalue->units);
printf("\n\t%8d %8d %8d %8d %8d %8d",
@@ -790,7 +791,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_ctrl_float *pvalue
= (struct dbr_ctrl_float *)pbuffer;
float *pfloat = &pvalue->value;
dbr_float_t *pfloat = &pvalue->value;
printf("%2d %2d %.8s",pvalue->status,pvalue->severity,
pvalue->units);
printf(" %3d\n\t%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f",
@@ -811,7 +812,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_ctrl_char *pvalue
= (struct dbr_ctrl_char *)pbuffer;
unsigned char *pchar = &pvalue->value;
dbr_char_t *pchar = &pvalue->value;
printf("%2d %2d %.8s",pvalue->status,pvalue->severity,
pvalue->units);
printf("\n\t%8d %8d %8d %8d %8d %8d",
@@ -851,7 +852,7 @@ LOCAL void print_returned(short type, char *pbuffer, short count)
{
struct dbr_ctrl_double *pvalue
= (struct dbr_ctrl_double *)pbuffer;
double *pdouble = &pvalue->value;
dbr_double_t *pdouble = &pvalue->value;
printf("%2d %2d %.8s",pvalue->status,pvalue->severity,
pvalue->units);
printf(" %3d\n\t%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f",

View File

@@ -43,22 +43,28 @@
* .06 091192 joh now uses SO_KEEPALIVE
* .07 091192 joh added SCCS ID
* .08 092292 joh improved message sent to the log
* .09 050494 pg HPUX port changes.
* .08 092292 joh improved message sent to the log
* .09 050494 pg HPUX port changes.
* .10 021694 joh ANSI C
*/
static char *pSCCSID = "@(#)iocLogServer.c 1.9\t05/05/94";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <envDefs.h>
#include <fdmgr.h>
static long ioc_log_port;
static struct in_addr ioc_log_addr;
static long ioc_log_file_limit;
static char ioc_log_file_name[64];
@@ -70,13 +76,6 @@ static char ioc_log_file_name[64];
#define FALSE 0
#endif
void acceptNewClient();
void readFromClient();
void logTime();
int getConfig();
int openLogFile();
void handleLogFileError();
void envFailureNotify();
struct iocLogClient {
int insock;
@@ -95,8 +94,6 @@ struct ioc_log_server {
void *pfdctx;
};
extern int errno;
#ifndef ERROR
#define ERROR -1
#endif
@@ -105,13 +102,21 @@ extern int errno;
#define OK 0
#endif
static void acceptNewClient (struct ioc_log_server *pserver);
static void readFromClient (struct iocLogClient *pclient);
static void logTime (struct iocLogClient *pclient);
static int getConfig(void);
static int openLogFile(struct ioc_log_server *pserver);
static void handleLogFileError(void);
static void envFailureNotify(ENV_PARAM *pparam);
/*
*
* main()
*
*/
main()
int main()
{
struct sockaddr_in serverAddr; /* server's address */
struct timeval timeout;
@@ -121,8 +126,8 @@ main()
status = getConfig();
if(status<0){
printf("iocLogServer: EPICS environment underspecified\n");
printf("iocLogServer: failed to initialize\n");
fprintf(stderr, "iocLogServer: EPICS environment underspecified\n");
fprintf(stderr, "iocLogServer: failed to initialize\n");
exit(ERROR);
}
@@ -152,8 +157,9 @@ main()
&optval,
sizeof(optval));
if(status<0){
ca_printf( "%s: set socket option failed\n",
__FILE__);
fprintf(stderr,
"%s: set socket option failed\n",
__FILE__);
}
/* Zero the sock_addr structure */
@@ -164,9 +170,10 @@ main()
/* get server's Internet address */
status = bind(pserver->sock, &serverAddr, sizeof serverAddr);
if (status<0) {
printf( "ioc log server allready installed on port %d?\n",
fprintf(stderr,
"ioc log server allready installed on port %ld?\n",
ioc_log_port);
exit();
exit(ERROR);
}
/* listen and accept new connections */
@@ -177,9 +184,10 @@ main()
status = openLogFile(pserver);
if(status<0){
printf( "File access problems `%s'\n",
fprintf(stderr,
"File access problems `%s'\n",
ioc_log_file_name);
exit();
exit(ERROR);
}
status = fdmgr_add_fd(
@@ -204,9 +212,7 @@ main()
* openLogFile()
*
*/
static int
openLogFile(pserver)
struct ioc_log_server *pserver;
static int openLogFile(struct ioc_log_server *pserver)
{
if(pserver->poutfile){
pserver->poutfile = freopen(
@@ -228,14 +234,12 @@ struct ioc_log_server *pserver;
* handleLogFileError()
*
*/
static void
handleLogFileError(pserver)
struct ioc_log_server *pserver;
static void handleLogFileError(void)
{
int status;
printf("iocLogServer: log file access problem (errno=%d)\n", errno);
exit();
fprintf(stderr,
"iocLogServer: log file access problem (errno=%s)\n",
strerror(errno));
exit(ERROR);
}
@@ -245,9 +249,7 @@ struct ioc_log_server *pserver;
* acceptNewClient()
*
*/
static void
acceptNewClient(pserver)
struct ioc_log_server *pserver;
static void acceptNewClient(struct ioc_log_server *pserver)
{
struct iocLogClient *pclient;
int size;
@@ -265,7 +267,7 @@ struct ioc_log_server *pserver;
pclient->insock = accept(pserver->sock, NULL, 0);
if(pclient->insock<0){
free(pclient);
printf("Accept Error %d\n", errno);
fprintf(stderr, "Accept Error %d\n", errno);
return;
}
@@ -322,7 +324,7 @@ struct ioc_log_server *pserver;
&true,
sizeof true);
if(status<0){
printf("Keepalive option set failed\n");
fprintf(stderr, "Keepalive option set failed\n");
}
}
@@ -341,9 +343,7 @@ struct ioc_log_server *pserver;
*/
#define NITEMS 1
static void
readFromClient(pclient)
struct iocLogClient *pclient;
static void readFromClient(struct iocLogClient *pclient)
{
int status;
int length;
@@ -361,7 +361,7 @@ readFromClient(pclient)
# ifdef DEBUG
if(length == 0){
printf("iocLogServer: nil message disconnect\n");
fprintf(stderr, "iocLogServer: nil message disconnect\n");
}
# endif
@@ -460,14 +460,15 @@ readFromClient(pclient)
if (length > pclient->pserver->max_file_size) {
# define FILE_BEGIN 0
# ifdef DEBUG
printf("ioc log server: resetting the file pointer\n");
fprintf(stderr,
"ioc log server: resetting the file pointer\n");
# endif
fseek(pclient->pserver->poutfile, 0, FILE_BEGIN);
status = ftruncate(
fileno(pclient->pserver->poutfile),
length);
if (status < 0) {
printf("truncation error %d\n", errno);
fprintf(stderr,"truncation error %d\n", errno);
}
}
}
@@ -480,9 +481,7 @@ readFromClient(pclient)
* logTime()
*
*/
static void
logTime(pclient)
struct iocLogClient *pclient;
static void logTime(struct iocLogClient *pclient)
{
time_t sec;
char *pcr;
@@ -506,10 +505,8 @@ logTime(pclient)
*
*
*/
static int
getConfig()
static int getConfig(void)
{
char inet_address_string[64];
int status;
char *pstring;
@@ -521,16 +518,6 @@ getConfig()
return ERROR;
}
#ifdef FETCH_INET_ADDR
status = envGetInetAddrConfigParam(
&EPICS_IOC_LOG_INET,
&ioc_log_addr);
if(status<0){
envFailureNotify(&EPICS_IOC_LOG_INET);
return ERROR;
}
#endif
status = envGetLongConfigParam(
&EPICS_IOC_LOG_FILE_LIMIT,
&ioc_log_file_limit);
@@ -558,10 +545,9 @@ getConfig()
*
*
*/
static void
envFailureNotify(pparam)
ENV_PARAM *pparam;
static void envFailureNotify(ENV_PARAM *pparam)
{
printf( "iocLogServer: EPICS environment variable `%s' undefined\n",
fprintf(stderr,
"iocLogServer: EPICS environment variable `%s' undefined\n",
pparam->name);
}