📄 tsip_cmd.c
字号:
/*
* *************************************************************************
*
* Trimble Navigation, Ltd.
* OEM Products Development Group
* P.O. Box 3642
* 645 North Mary Avenue
* Sunnyvale, California 94088-3642
*
* Corporate Headquarter:
* Telephone: (408) 481-8000
* Fax: (408) 481-6005
*
* Technical Support Center:
* Telephone: (800) 767-4822 (U.S. and Canada)
* (408) 481-6940 (outside U.S. and Canada)
* Fax: (408) 481-6020
* BBS: (408) 481-7800
* e-mail: trimble_support@trimble.com
*
* *************************************************************************
*
* Vers Date Changes Author
* ---- --------- ---------------------------------------- ----------
* v1.40
* 5a10 matched 5.10 manual pvwl
* *************************************************************************
*
* TSIP_CMD.C carries the function help_screen() displays the Keystroke
* Command List in the format (key packet Id description). For example,
* (t 0x21 show time) means the keystroke 't' must be pressed in order to
* request the time the receiver carries whether it is from an upload from
* the user/computer or from the GPS constellation. The TSIP commands are
* displayed in the Keystroke Command List in ascending hexadecimal order.
*
* A large case statement in proc_kbd() parses the keyboard inputs and
* directs processing to the mid-level function specific to the keyboard
* stroke. The called function then queries for user parameters and passes
* them to the appropriate command string generator cmd_0x?? in TSIP_IFC.C.
* The suffix convention for the command string generator follows:
*
* cmd_0x??q - query
* cmd_0x??s - set
* cmd_0x??c - clear/set to default
* cmd_0x??e - enable
* cmd_0x??d - disable
*
* In general, one command code corresponds to one or more keystrokes.
* There are two exceptions to this single-command model: Two functions
* called by proc_kbd(), almgetb() and almputb(), begin a series of tasks
* that get and load a full set of binary data from and into the receiver.
* When either functions get invoked, several commands and reports are
* generated before an exit to the main() function is performed.
*
* *************************************************************************
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include "tsip_ifc.h"
#include "tsipincl.h"
/*********************************************************************************************/
#define MAX_KB_CMDS 100
#define NUM_ALL_CMDS 48
static KB_CMD kb_all_cmd[NUM_ALL_CMDS] = {
{"^K", 0x0B, 0x1E, 0x45, "clear battery RAM"},
{" v", 'v', 0x1F, 0x45, "show S/W version "},
{" t", 't', 0x21, 0x41, "show time "},
{" z", 'z', 0x21, 0x41, "sync PC to UTC "},
{" i", 'i', 0x23, 0x00, "input XYZ pos "},
{" M", 'M', 0x24, 0x6D, "show 2D/3D mode "},
{"^R", 0x12, 0x25, 0x45, "reset receiver "},
{" h", 'h', 0x26, 0x46, "receiver health "},
{" s", 's', 0x27, 0x47, "show sig levels "},
{" m", 'm', 0x28, 0x48, "GPS sys message "},
{"^A", 0x01, 0x2A, 0x4A, "altitude for 2-D "},
{" I", 'I', 0x2B, 0x00, "input LLA pos "},
{" o", 'o', 0x2D, 0x4D, "show osc offset "},
{" T", 'T', 0x2E, 0x4E, "set time from PC "},
{" b", 'b', 0x31, 0x00, "set acc ECEF pos "},
{" B", 'B', 0x32, 0x00, "set acc LLA pos "},
{" O", 'O', 0x35, 0x55, "show I/O options "},
{"^O", 0x0F, 0x35, 0x55, "set I/O options "},
{" w", 'w', 0x37, 0x57, "show last fix "},
{" $", '$', 0x38, 0x58, "set/recv SV data "},
{" a", 'a', 0x38, 0x58, "show alm health "},
{" A", 'A', 0x38, 0x58, "show almanac "},
{" u", 'u', 0x38, 0x58, "show UTC data "},
{" e", 'e', 0x38, 0x58, "show ephemeris "},
{" d", 'd', 0x39, 0x59, "enable/disable SV"},
{" <", '<', 0x3A, 0x5A, "show raw meas "},
{" >", '>', 0x3C, 0x5C, "show track status"},
{" D", 'D', 0x62, 0x82, "show DGPS mode "},
{" /", '/', 0x65, 0x85, "show DGPS info "},
{" l", 'l', 0x70, 0x70, "filter control "},
{" q", 'q', 0x7A, 0x7B, "NMEA output cntrl"},
{" =", '=', 0x8E, 0x8F, "extended cmds "},
{" p", 'p', 0xBB, 0xBB, "rcvr configure "},
{" U", 'U', 0xBC, 0xBC, "port configure "},
{" %", '%', 0x13, 0x00, "generic command "},
{" ", '\0', 0x00, 0x00, "end record "}
};
#define NUM_8E_CMDS 6
static KB_CMD kb_8e_cmd[NUM_8E_CMDS] = {
{" d", 'd', 0x15, 0x100 + 0x15, "datum index "},
{" f", 'f', 0x19, 0x100 + 0x19, "UTM control "},
{" g", 'g', 0x20, 0x100 + 0x20, "Std PosVel spkt "},
{" =", '=', 0x00, 0x00, "generic 8E pkt "},
{" ", '\0', 0x00, 0x00, "end record "}
};
#define NUM_REPEAT_CMDS 10
static KB_CMD kb_repeat_cmd[NUM_REPEAT_CMDS] = {
{" t", 't', 0x21, 0x41, "show time "},
{" o", 'o', 0x2D, 0x4D, "show osc offset "},
{" <", '<', 0x3A, 0x5A, "show raw meas "},
{" s", 's', 0x27, 0x47, "show sig levels "},
{" >", '>', 0x3C, 0x5C, "show track status"},
{" /", '/', 0x65, 0x85, "show DGPS info "},
{" ", '\0', 0x00, 0x00, "end record "}
};
#define ABLE_TEXT_LEN 4
#define ALT_TEXT_LEN 2
#define BAUD_TEXT_0x3D_LEN 10
#define BITS_PER_BYTETEXT_0x3D_LEN 4
#define FLOW_CNTRL_TEXT_LEN 5
#define FRMT_TEXT_LEN 2
#define IN_OUT_TEXT_LEN 4
#define MODE_TEXT_LEN 4
#define OP_TEXT_LEN 7
#define PARITYTEXT_0x3D_LEN 5
#define PREC_TEXT_LEN 2
#define PROTOCOLS_TEXT_LEN 5
#define PORT_TEXT_LEN 3
#define QUERY_TEXT_LEN 2
#define RAW_TEXT_LEN 2
#define REQ_SET_TEXT_LEN 2
#define RX_MODE_TEXT_LEN 2
#define SNR_TEXT_LEN 2
#define STOP_BIT_TEXT_0x3D_LEN 3
#define TIME_TEXT_LEN 2
#define TOGGLE_TEXT_LEN 2
#define TX_MODE_TEXT_LEN 6
#define TYPE_TEXT_LEN 7
#define MAX_SERIAL_TEXT_LEN 10
char
*st_baud_text_app [BAUD_TEXT_LEN] =
{"", "110", "300", "600", "1200", "2400", "4800", "9600",
"19200", "38400"},
*able_text2[ABLE_TEXT_LEN] =
{"DISABLE", "ENABLE " },
*databit_text_app [DATABIT_TEXT_LEN] =
{"5", "6", "7", "8"},
*dgps_mode_text2[DGPS_MODE_TEXT_LEN] =
{"manual GPS (DGPS off)", "manual DGPS (DGPS req'd)", "",
"auto DGPS/GPS", ""},
*dyn_text2 [DYN_TEXT_LEN] =
{"", "land", "sea", "air (default)", "static"},
*flow_cntrl_text[FLOW_CNTRL_TEXT_LEN] =
{"none", "RTS/CTS", "TX XON/XOFF", "TX XANY", "RX XON/XOFF"},
*in_out_text[IN_OUT_TEXT_LEN] =
{"off", "in/out", "in only", "out only"},
*parity_text [PARITY_TEXT_LEN] =
{"NONE", "ODD", "EVEN"},
*port_text [PORT_TEXT_LEN] =
{"COM1", "COM2", ""},
*pos_fix_text[POS_FIX_TEXT_LEN] =
{"automatic", "time only (0-D)", "", "horizontal (2-D)",
"full position (3-D)"},
*protocols_text[PROTOCOLS_TEXT_LEN] =
{"TAIP ", "TSIP ", "NMEA ", "RTCM ", " "},
*rcvr_port_text [RCVR_PORT_TEXT_LEN] =
{"Port 1", "Port 2", "Current Port"},
*req_set_text[REQ_SET_TEXT_LEN] =
{"Request", "Set"},
*stopbit_text[STOPBIT_TEXT_LEN] =
{"1", "2"},
*toggle_text[TOGGLE_TEXT_LEN] =
{"off", "on"},
*trackmode_text3[TRACKMODE_TEXT_LEN] =
{"mode unchanged", "over-determined 8", "weighted over-determined 8"}
;
/*********************************************************************************************/
/* Defines from Stinger Serial port config/TP task */
#define PORT_HS_NONE 0
#define PORT_HS_RTS_CTS 1
#define PORT_HS_TX_XON_XOFF 2
#define PORT_HS_TX_XANY 4 /* requires PORT_HS_TX_XON_XOFF as well */
#define PORT_HS_RX_XON_XOFF 8
#define TAIP 0x01
#define TSIP 0x02
#define NMEA 0x04
#define RTCM 0x08
#define DCOL 0x10
/* Generate Control-letter character */
#define cntrl(x) ((x)-'A'+0x01)
#define ask_int(x) ask_byte(x)
/* Utility to check on sv_prn values */
short prn_valid (unsigned char sv_prn)
{
if ((sv_prn > 0) && (sv_prn < 33)) {
return TRUE;
}
xprintf ("SV number must be between 1 and 32 inclusive");
return FALSE;
}
/**/
/* *************** USER-PROMPTING ROUTINES FOR COMMANDS ************** */
/* 0x1D */
static void set_osc_offset (void)
{
float
offset;
xprintf ("Input oscillator offset value?");
if (!ask_verify ()) {
set_cmd_esc (TRUE);
return;
}
offset = ask_dbl ("Set oscillator offset (Hz) to: ");
if (cmd_esc ()) return;
xprintf ("Reset offset to %g Hz?", offset);
if (!ask_verify_nocmdcrlf ()) {
set_cmd_esc (TRUE);
return;
}
cmd_0x1Ds (offset);
}
/**/
/* 0x23 */
static void set_initial_ECEF_position (void)
{
float
pos_ECEF[3];
pos_ECEF[0] = ask_dbl ("Enter ECEF x: "); if (cmd_esc ()) return;
pos_ECEF[1] = ask_dbl ("Enter ECEF y: "); if (cmd_esc ()) return;
pos_ECEF[2] = ask_dbl ("Enter ECEF z: "); if (cmd_esc ()) return;
xprintf ("Set new position to %g, %g, %g m ECEF?",
pos_ECEF[0], pos_ECEF[1], pos_ECEF[2]);
if (!ask_verify_nocmdcrlf ()) {
set_cmd_esc (TRUE);
return;
}
cmd_0x23 (pos_ECEF);
return;
}
/* 0x2A */
void set_altitude(void)
{
float
alt;
unsigned char
op_code;
static char
*op_text[3] = {"query", "set alt", "disable"};
op_code = pick_one ("Enter operation: ", op_text, 3);
if (cmd_esc ()) return;
switch (op_code)
{
case 0:
cmd_0x2Aq();
break;
case 1:
alt = ask_dbl("Enter reference altitude: ");
if (cmd_esc ()) break;
cmd_0x2As (alt) ;
break;
case 2:
xprintf ("Disable reference altitude?");
if (!ask_verify_nocmdcrlf ())
{
set_cmd_esc (TRUE);
break;
}
cmd_0x2Ad ();
break;
}
return ;
}
/* 0x2B */
static void set_initial_lla_position (void)
{
float
lat, lon, alt;
lat = ask_dbl ("Enter lat (
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -