fixed it so it doesn't crash if the user tries to write to a control when no monitors have been created. Also fixed it so it exits if it is unable to mount NFS.

This commit is contained in:
Gunther
1991-12-23 16:08:39 +00:00
parent 72931120b2
commit 723709b3f2

View File

@@ -35,7 +35,8 @@
* .04 09-12-91 bg Added semDelete for both keyboard and monitor
semaphores.
* .05 10-2-91 bg Fixed bug in display_monitors.
* ...
* .06 12-12-91 bg Fixed lopi so if you try to write to a monitor
* ... you will not crash.
*/
#include "lopi_def.h"
@@ -179,24 +180,60 @@ static VOID lopi_init(screen,que_num,pdata_flg,k_buff,val_in)
read_ptr = k_buff;
write_ptr = k_buff;
err_fd = creat("lopi_err",0666);
err_fd = open("lopi_err",UPDATE,0666);
if((err_fd = open("lopi_err",UPDATE,0666)) == ERROR){
printf("Aborting. Unable to open error file.\n");
taskResume(shellTaskId);
new_fd = ioGlobalStdGet(0,STD_ERR);
ca_task_exit();
semDelete(key_sem);
semDelete(mon_sem);
taskDelete(tid2);
taskDelete(tid1);
exit(1);
}
/* Build menu a from file called lopi.dat. Count the lines read in. This
is the number of files to lopi read in. */
is the number of display files read in. */
create_menu(d_menu,&n_lines);
get_displays(d_menu,n_lines,wind_array);
/* Gives user a chance to read error messages generated by get_displays. */
taskDelay(100);
/* Open a file descriptor for the serial terminal.
Set it to raw mode. */
if ((lopi_fd = open("/tyCo/0",UPDATE,0)) == ERROR){
printf("Aborting. Unable to open serial port file.\n");
taskResume(shellTaskId);
ca_task_exit();
status = ioctl(lopi_fd,FIOSETOPTIONS,OPT_TERMINAL);
new_fd = ioGlobalStdGet(0,STD_ERR);
semDelete(key_sem);
semDelete(mon_sem);
taskDelete(tid2);
taskDelete(tid1);
exit(1);
}
logFdSet(err_fd);
lopi_fd = open("/tyCo/0",UPDATE,0);
status = ioctl(lopi_fd,FIOSETOPTIONS,OPT_RAW);
if ((status = ioctl(lopi_fd,FIOSETOPTIONS,OPT_RAW)) == ERROR){
printf("Aborting. Unable to set I/O mode.\n");
taskResume(shellTaskId);
ca_task_exit();
new_fd = ioGlobalStdGet(0,STD_ERR);
status = ioctl(lopi_fd,FIOSETOPTIONS,OPT_TERMINAL);
semTake(key_sem);
semGive(key_sem);
semDelete(key_sem);
semDelete(mon_sem);
taskDelete(tid2);
taskDelete(tid1);
exit(1);
}
CLEAR_SCREEN
INIT_CURSOR
@@ -1444,10 +1481,7 @@ int nfiles;
/***************************************************************************************/
/* This function will spawn two child processes. One will asynchronously get data */
/* from the field and put it on the screen. The other will asynchronously get input */
/* from the keyboard and react to it . The second will run at a slightly higher */
/* priority than the first. */
/* This function puts text specified by the user in the display file on the screen. */
/***************************************************************************************/
static display_text(disp_array,selected)
@@ -1474,9 +1508,9 @@ static display_text(disp_array,selected)
}
/***************************************************************************************/
/* */
/* */
/* */
/* Displays a file chosen by the user from the display file which was created when */
/* the program initialized. Also calls put_value() to write to controls if the user */
/* selects and F7. */
/***************************************************************************************/
static display_file(disp_array,selected,screen_up,data_num,pdata_flg,k_buff,val_in)
@@ -1601,7 +1635,8 @@ static display_file(disp_array,selected,screen_up,data_num,pdata_flg,k_buff,val_
semGive(key_sem);
trow = BEG_BOX;
tcol = BEG_BOX;
put_value(c_ptr,val_in);
if(c_ptr != NULL)
put_value(c_ptr,val_in);
break;
case U_ARROW:
if (c_ptr != NULL)
@@ -1689,6 +1724,13 @@ static display_file(disp_array,selected,screen_up,data_num,pdata_flg,k_buff,val_
}
/********************************************************************************/
/* VOID display_monitors */
/* Uses a linked list of monitors and a doubly linked circular list of */
/* controls. Controls and monitors are treated the same as far as this */
/* subroutine is concerned. That is both are monitored. */
/********************************************************************************/
static VOID display_monitors(disp_array,m_select,screen,pdata_flg,init,except_ptr)
struct window_node *disp_array[MAX_DISP_NUM];
short m_select; /* Pointer to number of screen selected. */
@@ -1744,8 +1786,8 @@ static VOID display_monitors(disp_array,m_select,screen,pdata_flg,init,except_pt
ATR_OFF
status = ca_build_and_connect(ctl_ptr->chan,TYPENOTCONN,0,&ctl_ptr->chan_id,
NULL,lopi_conn_handler,ctl_ptr);
SEVCHK(status,NULL);
logMsg("build_and_connect for %s, status = %d\n",ctl_ptr->chan,status);
if (status != ECA_NORMAL)
logMsg(" ca_build_and_connect:%d\n",ca_message_text[CA_EXTRACT_MSG_NO(status)]);
ctl_ptr = ctl_ptr->next;
}
}
@@ -1769,9 +1811,9 @@ static VOID display_monitors(disp_array,m_select,screen,pdata_flg,init,except_pt
ESCAPE
ATR_OFF
status = ca_build_and_connect(mon_ptr->chan,TYPENOTCONN,0,&mon_ptr->chan_id,
NULL,lopi_conn_handler,mon_ptr);
logMsg("build_and_connect for %s, status = %d\n",mon_ptr->chan,status);
NULL,lopi_conn_handler,mon_ptr);
if (status != ECA_NORMAL)
logMsg(" ca_build_and_connect:%d\n",ca_message_text[CA_EXTRACT_MSG_NO(status)]);
mon_ptr = mon_ptr->next;
}
@@ -1781,7 +1823,6 @@ static VOID display_monitors(disp_array,m_select,screen,pdata_flg,init,except_pt
while (mon_ptr != NULL)
{
status = ca_add_event(DBR_STS_STRING,mon_ptr->chan_id,lopi_ev_handler,mon_ptr->ev_ptr,NULL);
SEVCHK(status,NULL);
if (status != ECA_NORMAL)
logMsg("Message:%d\n",ca_message_text[CA_EXTRACT_MSG_NO(status)]);
type = ca_field_type(mon_ptr->chan_id);
@@ -2223,6 +2264,8 @@ put_value(c_ptr,val_in)
be passes. */
{
status = ca_put(DBR_STRING,c_ptr->chan_id,((void *)val_in));
if (status != ECA_NORMAL)
logMsg("Message:%s\n",ca_message_text[CA_EXTRACT_MSG_NO(status)]);
if (DEBUG)
logMsg("Putting %s to %s\n",val_in,c_ptr->chan);
status = ca_flush_io();