~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/tools/serial/serial_tool.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* serial_tool.c
  2  *
  3  * interface for serialisation system.
  4  * controls socket communication system and data transmission
  5  * and reception.
  6  * 
  7  */
  8 
  9 #include <stdio.h>
 10 #include <sys/param.h>
 11 #include <string.h>
 12 #include <tina/sys.h>
 13 #include <tina/sysfuncs.h>
 14 
 15 
 16 static char  remote_hostname[256];
 17 static char  srlsvr_status[64] = "offline";
 18 static char  srlclnt_status[64] = "disconnected";
 19 static int   remote_portnumber;
 20 static void *prh, *prp, *pss, *psc;
 21 
 22 
 23 char *get_srlsvr_status()
 24 {
 25         return srlsvr_status;
 26 }
 27 
 28 /* dummy so that users cannot change status */
 29 void  set_srlsvr_status(char *p)
 30 {
 31         tw_svalue_reset(pss);
 32 }
 33 
 34 /* actual status modifier */
 35 void    put_srlsvr_status(char *p)
 36 {
 37         strncpy(srlsvr_status, p, 64);
 38         tw_svalue_reset(pss);
 39 }       
 40 
 41 char *get_srlclnt_status()
 42 {
 43         return srlclnt_status;
 44 }
 45 
 46 /* dummy so that users cannot change status */
 47 void  set_srlclnt_status(char *p)
 48 {
 49         tw_svalue_reset(psc);
 50 }
 51 
 52 /* actual status modifier */
 53 void    put_srlclnt_status(char *p)
 54 {
 55         strncpy(srlclnt_status, p, 64);
 56         tw_svalue_reset(psc);
 57 }       
 58 
 59 
 60 
 61 static void start_server_proc(int val)
 62 {
 63                 serial_server_start();
 64 }
 65 
 66 
 67 static void stop_server_proc(int val)
 68 {
 69                 serial_server_stop();
 70 }
 71 
 72 
 73 static void connect_proc(void)
 74 {
 75         serial_connect(remote_hostname);
 76 }
 77 
 78 static void disconnect_proc(void)
 79 {
 80         serial_disconnect();
 81 }
 82 
 83 static void transmit_proc(void)
 84 {
 85         int     fd = get_serial_ssockid();
 86 
 87         serial_sndim_fromtos(fd);
 88 }
 89 
 90 
 91 /* Tool creation */
 92 void    serial_tool(int x, int y)
 93 {
 94     static void *tv_screen = NULL;
 95                 char    *get_srlsvr_status();
 96                 void   set_srlsvr_status(char *p);
 97 
 98     if (tv_screen)
 99     {
100                         tw_show_tool(tv_screen);
101                         return;
102     }
103     
104                 tv_screen = (void *)tw_tool("Serialise Tool", x, y);
105 
106                 tw_label("server  ");
107     tw_button("start", start_server_proc, NULL);
108     tw_button("stop", stop_server_proc, NULL);
109     pss = (void *) tw_svalue(" status:", get_srlsvr_status, set_srlsvr_status, 12);
110                 
111                 tw_newrow();
112                 tw_label("client  ");
113     tw_button("conct", connect_proc, NULL);
114     tw_button("d/ct", disconnect_proc, NULL);
115     psc = (void *) tw_svalue(" status:", get_srlclnt_status, set_srlclnt_status, 12);
116 
117     tw_newrow();
118                 tw_label("host  ");
119     prh = (void *) tw_sglobal("name :", remote_hostname, 32);
120     prp = (void *) tw_iglobal("port :", &remote_portnumber, 5);
121 
122     tw_newrow();
123     tw_button("send", transmit_proc, NULL);
124 
125     tw_end_tool();
126 }
127 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.