adding help() to test program

This commit is contained in:
tth 2019-02-22 15:55:50 +01:00
父節點 c0f3e128aa
當前提交 c381b61b60
共有 1 個檔案被更改,包括 10 行新增2 行删除

查看文件

@ -51,6 +51,14 @@ for (count=0; count<iters; count++) {
return 0;
}
/* ---------------------------------------------------------------- */
void help(int k)
{
puts("options : ");
puts("\t-d\tserial device to read.");
puts("\t-n\tnumber of records to grab.");
puts("\t-v\tincrease verbosity.");
}
/* ---------------------------------------------------------------- */
int main (int argc, char *argv[])
{
int serial_in;
@ -62,12 +70,12 @@ verbosity = 0;
nbre = 25;
speed = 9600;
while ((opt = getopt(argc, argv, "d:n:v")) != -1) {
while ((opt = getopt(argc, argv, "d:n:vh")) != -1) {
switch (opt) {
case 'v': verbosity++; break;
case 'n': nbre = atoi(optarg); break;
case 'd': device = optarg; break;
case 'h': help(0); exit(0);
default:
fprintf(stderr, "%s : uh ?", argv[0]);
exit(1);