Changeset 4601


Ignore:
Timestamp:
08/21/08 09:48:11 (5 years ago)
Author:
werner
Message:

Committing changes that have piled up. The things under lib/ are ugly,
incomplete, and buggy. Don't try to use them yet.

  • usbtmc.c: improper handling of the "vendor=" option
  • telnet.c: added option "nl" to suppress warning on extra newline (note that this makes parameter parsing ambiguous - to be fixed later)
  • lib/: added a number of Python scripts to implement properly abstracted access to instruments (work in progress, still very limited)
Location:
developers/werner/ahrt/host/tmc
Files:
8 added
2 edited

Legend:

Unmodified
Added
Removed
  • developers/werner/ahrt/host/tmc/telnet.c

    r4228 r4601  
    5757        int sd;         /* socket descriptor */ 
    5858        int crlf;       /* 0 = in message, 1 = CR seen, 2 = CRLF seen */ 
     59        int nl;         /* 0 = complain about extra \n, 1 = don't */ 
    5960        int max_tries;  /* number of times we try to set up the connection */ 
    6061        int tries_left; /* number of attempts left */ 
     
    6768static void usage(void) 
    6869{ 
    69         fprintf(stderr, "usage: \"telnet\", [tries=N,] host [, port]\n"); 
     70        fprintf(stderr, "usage: \"telnet\", [tries=N,] [nl,] host [, port]\n"); 
    7071} 
    7172 
     
    106107        unsigned long num; 
    107108        char *end; 
    108  
    109         if (argc && strchr(argv[0], '=')) { 
    110                 if (strncmp(argv[0], "tries=", 6)) { 
    111                         usage(); 
    112                         return NULL; 
    113                 } 
    114                 tries = strtoul(argv[0]+6, &end, 0); 
    115                 if (*end || !tries) { 
    116                         usage(); 
    117                         return NULL; 
    118                 } 
    119                 argc--; 
    120                 argv++; 
    121         } 
    122         if (!argc || argc > 2) { 
    123                 usage(); 
    124                 return NULL; 
    125         } 
    126         host = argv[0]; 
    127         port = argc == 2 ? argv[1] : DEFAULT_PORT; 
     109        int i; 
    128110 
    129111        d = malloc(sizeof(struct telnet_dsc)); 
     
    132114                return NULL; 
    133115        } 
     116        d->nl = 0; 
     117 
     118        for (i = 0; i != argc; i++) { 
     119                if (!strncmp(argv[i], "tries=", 6)) { 
     120                        tries = strtoul(argv[0]+6, &end, 0); 
     121                        if (*end || !tries) { 
     122                                usage(); 
     123                                return NULL; 
     124                        } 
     125                } 
     126                else if (!strcmp(argv[i], "nl")) { 
     127                        d->nl = 1; 
     128                } 
     129                else 
     130                        break; 
     131        } 
     132        if (i == argc || i-argc > 2) { 
     133                usage(); 
     134                return NULL; 
     135        } 
     136        host = argv[i]; 
     137        port = argc > i+1 ? argv[i+1] : DEFAULT_PORT; 
     138 
    134139        d->crlf = 0; 
    135140 
     
    264269                                break; 
    265270                        case '\n': 
    266                                 if (d->crlf != 1) 
     271                                if (d->crlf != 1 && !d->nl) 
    267272                                        fprintf(stderr, 
    268273                                            "warning: unexpected \\n\n"); 
  • developers/werner/ahrt/host/tmc/usbtmc.c

    r4526 r4601  
    453453                } 
    454454                else if (!strncmp(argv[i], "vendor=", 7)) { 
    455                         device = strtoul(argv[i]+7, &end, 0); 
     455                        vendor = strtoul(argv[i]+7, &end, 0); 
    456456                        if (*end || !vendor || vendor > 0xffff) 
    457457                                goto usage; 
Note: See TracChangeset for help on using the changeset viewer.