Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions sscanApp/Db/saveData.db
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,31 @@ record(stringout, "$(P)saveData_fileName") {
field(DTYP, "Soft Channel")
}

record(stringout, "$(P)saveData_fileSystem") {
record(waveform, "$(P)saveData_fileSystem") {
field(DTYP, "Soft Channel")
field(NELM, "256")
field(FTVL, "CHAR")
}

record(stringout, "$(P)saveData_message") {
field(DTYP, "Soft Channel")
}

record(stringout, "$(P)saveData_subDir") {
record(waveform, "$(P)saveData_subDir") {
field(DTYP, "Soft Channel")
field(NELM, "256")
field(FTVL, "CHAR")
}

record(stringout, "$(P)saveData_baseName") {
record(waveform, "$(P)saveData_baseName") {
field(DTYP, "Soft Channel")
field(NELM, "256")
field(FTVL, "CHAR")
}

record(waveform, "$(P)saveData_fullPathName") {
field(DTYP, "Soft Channel")
field(NELM, "100")
field(NELM, "512")
field(FTVL, "CHAR")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you miss this record intentionally?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That has always been a waveform, so I didn't necessarily want to change it and potentially affect functionality beyond what was asked for. But if the recommendation is to phase out waveforms, I will change it.


Expand Down
76 changes: 43 additions & 33 deletions sscanApp/src/saveData_writeXDR.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
#define DESC_SIZE 30
#define EGU_SIZE 16
#define PREFIX_SIZE PVNAME_STRINGSZ/2
#define BASENAME_SIZE 20
#define COMPONENT_STRING_SIZE 256

#include "req_file.h"
#include "writeXDR.h"
Expand Down Expand Up @@ -352,7 +352,7 @@ LOCAL const char save_data_version[]=SAVE_DATA_VERSION;
#define HANDSHAKE_BUSY 1
#define HANDSHAKE_DONE 0

#define FNAMELEN 100
#define FNAMELEN 512
typedef struct scan {
/*========================= PRIVATE FIELDS ===========================*/
short state; /* state of the structure */
Expand Down Expand Up @@ -460,7 +460,7 @@ typedef struct scan {
/*---------------------- saveDataTask's message queue ------------------*/

#define MAX_MSG 1000 /* max # of messages in saveDataTask's queue */
#define MAX_SIZE 80 /* max size in byte of the messages */
#define MAX_SIZE 512 /* max size in byte of the messages */

#define MSG_SCAN_DATA 1 /* save scan */
#define MSG_SCAN_NPTS 2 /* NPTS changed */
Expand Down Expand Up @@ -571,15 +571,15 @@ typedef struct string_msg {
int type;
epicsTimeStamp time;
char* pdest; /* specified as user arg in ca_create_subscription() call */
char string[MAX_STRING_SIZE];
char string[COMPONENT_STRING_SIZE];
} STRING_MSG;

#define STRING_SIZE (sizeof(STRING_MSG)<MAX_SIZE? \
sizeof(STRING_MSG):MAX_SIZE)

#define sendStringMsgWait(t,d,s) { \
STRING_MSG msg; \
msg.type=t; msg.pdest=(char*)d; strncpy(msg.string, s, MAX_STRING_SIZE); \
msg.type=t; msg.pdest=(char*)d; strncpy(msg.string, s, COMPONENT_STRING_SIZE); \
epicsTimeGetCurrent(&(msg.time)); \
epicsMessageQueueSend(msg_queue, (void *)&msg, \
STRING_SIZE); }
Expand Down Expand Up @@ -627,9 +627,9 @@ typedef struct pv_node {
LOCAL char req_file[40];
LOCAL char req_macros[40];

LOCAL char server_pathname[200];
LOCAL char server_pathname[COMPONENT_STRING_SIZE];
LOCAL char* server_subdir;
LOCAL char local_pathname[200];
LOCAL char local_pathname[COMPONENT_STRING_SIZE];
LOCAL char* local_subdir;

#define STATUS_INACTIVE 0
Expand Down Expand Up @@ -661,7 +661,7 @@ LOCAL chid realTime1D_chid;
LOCAL long counter; /* data file counter*/
LOCAL chid counter_chid;
LOCAL char ioc_prefix[PREFIX_SIZE];
LOCAL char scanFile_basename[BASENAME_SIZE] = "";
LOCAL char scanFile_basename[COMPONENT_STRING_SIZE] = "";

/* file-write retries */
LOCAL chid maxAllowedRetries_chid;
Expand Down Expand Up @@ -756,7 +756,7 @@ LOCAL int checkRWpermission(char* path) {
/* Quick and dirty way to check for R/W permission */
int file;
char tmpfile[100];

strncpy(tmpfile, path, 100);
strncat(tmpfile, "/rix_", 100-strlen(tmpfile));

Expand Down Expand Up @@ -815,8 +815,9 @@ void saveData_Init(char* fname, char* macros)
epicsThreadSuspendSelf();
}
}
else
else {
printf("saveData already initialized\n");
}

return;
}
Expand Down Expand Up @@ -1670,17 +1671,17 @@ LOCAL void descMonitor(struct event_handler_args eha)

LOCAL void fileSystemMonitor(struct event_handler_args eha)
{
sendStringMsgWait(MSG_FILE_SYSTEM, NULL, eha.dbr);
sendStringMsgWait(MSG_FILE_SYSTEM, NULL, (const char*) eha.dbr);
}

LOCAL void fileSubdirMonitor(struct event_handler_args eha)
{
sendStringMsgWait(MSG_FILE_SUBDIR, NULL, eha.dbr);
sendStringMsgWait(MSG_FILE_SUBDIR, NULL, (const char*) eha.dbr);
}

LOCAL void fileBasenameMonitor(struct event_handler_args eha)
{
sendStringMsgWait(MSG_FILE_BASENAME, NULL, eha.dbr);
{
sendStringMsgWait(MSG_FILE_BASENAME, NULL, (const char*) eha.dbr);
}

LOCAL void realTime1DMonitor(struct event_handler_args eha)
Expand Down Expand Up @@ -1708,14 +1709,16 @@ LOCAL int connectFileSystem(char* fs)

epicsSnprintf(fs_disp, 80, "%s.DISP", fs);

ca_search(fs, &file_system_chid);
ca_search(fs_disp, &file_system_disp_chid);
ca_create_channel(fs, NULL, NULL, 0, &file_system_chid);
//ca_search(fs_disp, &file_system_disp_chid);
if (ca_pend_io(0.5)!=ECA_NORMAL) {
printf("saveData: Unable to connect %s\nsaveDataTask not initialized\n", fs);
return -1;
} else {
if (ca_add_event(DBR_STRING, file_system_chid,
fileSystemMonitor, NULL, NULL)!=ECA_NORMAL) {
evid id;

if (ca_create_subscription(DBR_CHAR, COMPONENT_STRING_SIZE, file_system_chid, DBE_VALUE,
fileSystemMonitor, NULL, &id)!=ECA_NORMAL) {
printf("saveData: Can't monitor %s\nsaveDataTask not initialized\n", fs);
ca_clear_channel(file_system_chid);
return -1;
Expand All @@ -1729,14 +1732,17 @@ LOCAL int connectSubdir(char* sd)
char sd_disp[80];

epicsSnprintf(sd_disp, 80, "%s.DISP", sd);
ca_search(sd, &file_subdir_chid);
ca_search(sd_disp, &file_subdir_disp_chid);

ca_create_channel(sd, NULL, NULL, 0, &file_subdir_chid);
//ca_search(sd_disp, &file_subdir_disp_chid);
if (ca_pend_io(0.5)!=ECA_NORMAL) {
printf("saveData: Unable to connect %s\nsaveDataTask not initialized\n", sd);
return -1;
} else {
if (ca_add_event(DBR_STRING, file_subdir_chid,
fileSubdirMonitor, NULL, NULL)!=ECA_NORMAL) {
evid id;

if (ca_create_subscription(DBR_CHAR, COMPONENT_STRING_SIZE, file_subdir_chid, DBE_VALUE,
fileSubdirMonitor, NULL, &id)!=ECA_NORMAL) {
printf("saveData: Can't monitor %s\nsaveDataTask not initialized\n", sd);
ca_clear_channel(file_subdir_chid);
return -1;
Expand All @@ -1750,15 +1756,17 @@ LOCAL int connectBasename(char* bn)
char bn_disp[80];

epicsSnprintf(bn_disp, 80, "%s.DISP", bn);
ca_search(bn, &file_basename_chid);
ca_search(bn_disp, &file_basename_disp_chid);
ca_create_channel(bn, NULL, NULL, 0, &file_basename_chid);
//ca_search(bn_disp, &file_basename_disp_chid);
if (ca_pend_io(0.5)!=ECA_NORMAL) {
printf("saveData: Unable to connect %s\n", bn);
file_basename_chid = NULL;
return 0;
} else {
if (ca_add_event(DBR_STRING, file_basename_chid,
fileBasenameMonitor, NULL, NULL)!=ECA_NORMAL) {
evid id;

if (ca_create_subscription(DBR_CHAR, COMPONENT_STRING_SIZE, file_basename_chid, DBE_VALUE,
fileBasenameMonitor, NULL, &id)!=ECA_NORMAL) {
printf("saveData: Can't monitor %s\n", bn);
ca_clear_channel(file_basename_chid);
file_basename_disp_chid = NULL;
Expand Down Expand Up @@ -2045,7 +2053,7 @@ LOCAL int initSaveDataTask()

server_pathname[0]= '\0';
server_subdir= server_pathname;
strncpy(local_pathname, "/data/", 200);
strncpy(local_pathname, "/data/", COMPONENT_STRING_SIZE);
local_subdir= &local_pathname[strlen(local_pathname)];

rf= req_open_file(req_file, req_macros);
Expand Down Expand Up @@ -2358,6 +2366,7 @@ LOCAL int writeScanRecInProgress(SCAN *pscan, epicsTimeStamp stamp, int isRetry)
/* Attempt to open data file */
Debug1(3, "saveData:writeScanRecInProgress: Opening file '%s'\n", pscan->ffname);
epicsTimeGetCurrent(&openTime);

fd = fopen(pscan->ffname, pscan->first_scan ? "wb+" : "rb+");

if ((fd==NULL) || (fileStatus(pscan->ffname) == ERROR)) {
Expand Down Expand Up @@ -2918,7 +2927,7 @@ LOCAL void proc_scan_data(SCAN_TS_SHORT_MSG* pmsg)
}
/* Make file name */
if (scanFile_basename[0] == '\0') {
strncpy(scanFile_basename, ioc_prefix, BASENAME_SIZE);
strncpy(scanFile_basename, ioc_prefix, COMPONENT_STRING_SIZE);
}
epicsSnprintf(pscan->fname, FNAMELEN, "%s%.4d.mda", scanFile_basename, (int)pscan->counter);
#ifdef vxWorks
Expand Down Expand Up @@ -3560,7 +3569,7 @@ LOCAL void remount_file_system(char* filesystem)
#ifdef vxWorks
nfsUnmount("/data");
#endif

file_system_state= FS_NOT_MOUNTED;
save_status= STATUS_ACTIVE_FS_ERROR;

Expand All @@ -3580,6 +3589,7 @@ LOCAL void remount_file_system(char* filesystem)
/* extract the host name */
int i = 0;
cout= hostname;

while ((*filesystem!='\0') && (*filesystem!='/') && i<40) {
*(cout++)= *(filesystem++);
i++;
Expand Down Expand Up @@ -3611,8 +3621,8 @@ LOCAL void remount_file_system(char* filesystem)
#endif

if (file_system_state == FS_MOUNTED) {
strncpy(server_pathname, filesystem, 200);
strncat(server_pathname, "/", 200-strlen(server_pathname));
strncpy(server_pathname, filesystem, COMPONENT_STRING_SIZE);
strncat(server_pathname, "/", COMPONENT_STRING_SIZE-strlen(server_pathname));
server_subdir= &server_pathname[strlen(server_pathname)];

if (checkRWpermission(path)!=OK) {
Expand Down Expand Up @@ -3711,8 +3721,8 @@ LOCAL void proc_file_subdir(STRING_MSG* pmsg)

LOCAL void proc_file_basename(STRING_MSG* pmsg)
{
strncpy(scanFile_basename, pmsg->string, BASENAME_SIZE-1);
scanFile_basename[BASENAME_SIZE-1] = '\0';
strncpy(scanFile_basename, pmsg->string, COMPONENT_STRING_SIZE-1);
scanFile_basename[COMPONENT_STRING_SIZE-1] = '\0';
DebugMsg1(2, "MSG_FILE_BASENAME(%s)\n", pmsg->string);
}

Expand Down
Loading