[Dsctl-devel] SF.net SVN: dsctl: [142] src
Status: Alpha
Brought to you by:
roger-linux
|
From: <rog...@us...> - 2007-11-12 22:07:51
|
Revision: 142
http://dsctl.svn.sourceforge.net/dsctl/?rev=142&view=rev
Author: roger-linux
Date: 2007-11-12 14:07:47 -0800 (Mon, 12 Nov 2007)
Log Message:
-----------
src/commands.c - Added: New commands/functions.
Fixed: BKL not getting all of it's data.
Added: Stubs/comments for future commands/functions.
src/commands.c - Added: Completed commands/functions. (Still needs
implementing & testing. See commands.c for TODO comments.)
src/commands.h - Trivial: Uncommented remainder function names today.
(Corrected a few of the newly uncommented functions.)
TODO - Trivial: Adjusted comments reflecting work completed today.
Modified Paths:
--------------
TODO
src/commands.c
src/commands.h
Modified: TODO
===================================================================
--- TODO 2007-11-11 21:28:54 UTC (rev 141)
+++ TODO 2007-11-12 22:07:47 UTC (rev 142)
@@ -1,56 +1,56 @@
1) Implementing the commands according to the BCD996T_Protocol.pdf
is simply the only things left to do besides some bugs
- concerning serial communication. Most of the protocol commands,
- if not all of them, are located within the commands.c file.
+ concerning serial communication. Most of the functions for the
+ commands, if not all of them, are located within the commands.c
+ file. Work is primarily done for the BCD996T. BCD396T has similar
+ commands, but no work has currently been done to ensure 100%
+ compatability. This can be easily done though if somebody has
+ a BCD396T and some time for submitting bug reports.
I've completed almost all the _get_ commands to retrieve data
from the units including some of the _set_ commands to send
data to the unit. To see what I haven't done yet, look at the
- commands.h file for commented function declarations. Obviously,
- these are the functions (aka scanner commands) needing
- implementing.
+ commands.c for for TODO comments. Currently, all the commands have
+ been written into functions, they just need to be further
+ implemented or hooked into the upper-level load() and dump()
+ functions. Testing is also needed with these. (*See TODO comments
+ within commands.c.)
- It's quite easy really. You can basically copy/paste over most
- of the code within the previous functions according to whether
- it's a get_ or set_ command. You just need to either read the
- returned comma parsed string into the proper varaibles for
- printing. If the command is to _set or send data, again, the
- string needs to be read in from file and formated properly before
- sending the string to the scanner.
+ I've even found the undocumented commands for uploading firmware.
+ Status of these are the same as above, they just need implemented
+ and testing.
- I've even found the commands for uploading firmware.
-
- The only gotcha, I tried implementing a delay into the serial.c
+ The only hiccup, I tried implementing a delay into the serial.c
with hopes of the program detecting a stall and quiting instead
of locking the computer with the system call. You may notice the
delay values somewhere between 10 seconds to 45+ seconds for
downloading or uploading. For loading the firmware, it can take
- more then 5 minutes.
+ more then 5 minutes. The function in serial.c for checking delays
+ needs to know these as so not to confuse the time span as a hang.
I, or somebody else, might consider re-writing the code once the
- functions are implemented for easier reading. Should probably use
- structs?
+ functions are implemented for easier reading. (Should probably use
+ structs?)
- If you look at the protocol pdf file, I'm also missing APPEND
- functions.
-
2) Some sort of frontend is needed for programming this scanner.
There's just too much loose data, requiring specific ranges, etc,
for a simple user to enter by hand. I'm up for ideas here.
Gnome or ncurses based UI??? Well, I do have autoconfig/automake
installed, albeit, roughly.
- One method probably doesn't require much of a frontend, direct
- downloading for radioreference.com. However, users generally
- still have to fill in TGID's after searching for them on an
- APCO based system.
+ One method probably doesn't require much of a frontend is, direct
+ downloading from radioreference.com. However, users generally
+ still have to fill in TGID's after searching for them on their
+ scanned system since some TGID's are not listed.
-3) I do have a basic command implemented for Live Streaming via
- Icecast. The stream is also updated with the active frequency data.
+3) I do have a basic command implemented for Live Streaming to
+ Icecast. The stream is also updated with the active frequency data
+ called metadata (ie ~/.dsctl/metadata).
There's a bug, after a time period of streaming, the
ncurses display will freeze, but it basically works. (Think the
- bug/freeze is encountered with certain freq/band is hit.)
+ bug/freeze is encountered with serial buffering. Could be this code
+ or something in the kernel.)
4) Future:
a) Possible rewrite using structs instead of all arrays and
Modified: src/commands.c
===================================================================
--- src/commands.c 2007-11-11 21:28:54 UTC (rev 141)
+++ src/commands.c 2007-11-12 22:07:47 UTC (rev 142)
@@ -2004,7 +2004,7 @@
/***********************************************************************
* Get Location Alert System Index Head
***********************************************************************/
-/* TODO: This needs to be tested/checked. */
+/* TODO: This needs to be implemented & tested */
int loc_alert_system_index_head(int fd, char *loc_alert_system_type)
{
char answer[100], command[100];
@@ -2050,11 +2050,61 @@
/***********************************************************************
* Create Location Alert System
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int create_loc_alert_system(int fd, char *loc_alert_system_type)
+{
+ char answer[100], command[100];
+ int system_index = 0;
+ memset(answer, 0, 100);
+ memset(command, 0, 100);
+
+ snprintf(command, 100, "CLA,%s", loc_alert_system_type);
+ /*printf("\nCommand == %s\n", command); */
+ do_command(fd, command, answer);
+ /*printf("%s\n(%i)\n", answer, strlen(answer)); */
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "CLA,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ sscanf(answer, "CSY,%d", &system_index);
+
+ return (system_index);
+}
+
/***********************************************************************
* Delete Location Alert System
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int delete_loc_alert_system(int fd, int loc_alert_system_index)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 100);
+ memset(command, 0, 500);
+
+ snprintf(command, 500,
+ "DLA,%i",loc_alert_system_index );
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "DLA,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return(0);
+}
+
/***********************************************************************
* Get Location Alert System Info
***********************************************************************/
@@ -2094,7 +2144,35 @@
/***********************************************************************
* Set Location Alert System Info
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_loc_alert_system_info(int fd, int loc_alert_system_index, char **parsed_line)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 100);
+ memset(command, 0, 500);
+
+ snprintf(command, 500,
+ "LIN,%i,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s",
+ loc_alert_system_index, parsed_line[1], parsed_line[2], parsed_line[3],
+ parsed_line[4], parsed_line[5], parsed_line[8], parsed_line[9],
+ parsed_line[10], parsed_line[11], parsed_line[12],
+ parsed_line[13]);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "LIN,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get Search/Close Call Settings
***********************************************************************/
@@ -2127,13 +2205,36 @@
}
/***********************************************************************
-* Get Search/Close Call Settings
-***********************************************************************/
-
-/***********************************************************************
* Set Search/Close Call Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_srch_cc_settings(int fd, char **parsed_line)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 100);
+ memset(command, 0, 500);
+
+ snprintf(command, 500,
+ "SCO,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s",
+ parsed_line[1], parsed_line[2], parsed_line[3],
+ parsed_line[4], parsed_line[5], parsed_line[6], parsed_line[7],
+ parsed_line[8], parsed_line[9], parsed_line[10], parsed_line[11], parsed_line[12]);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "SCO,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get Broadcast Screen Band Settings
***********************************************************************/
@@ -2172,7 +2273,31 @@
/***********************************************************************
* Set Broadcast Screen Band Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_bcast_screen_band_settings(int fd, int bcast_screen_band_settings_index, char **parsed_line)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "BBS,%i,%s,%s", bcast_screen_band_settings_index,
+ parsed_line[1], parsed_line[2]);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "BBS,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get Search Key Settings
***********************************************************************/
@@ -2207,7 +2332,31 @@
/***********************************************************************
* Set Search Key Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_search_key_settings(int fd, char **parsed_line)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "SHK,%s,%s,%s,%s,%s,%s", parsed_line[1],
+ parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5], parsed_line[6]);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "SHK,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get Global Lockout Frequency
***********************************************************************/
@@ -2253,11 +2402,57 @@
/***********************************************************************
* Unlock Global Lockout
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int unlock_global_lockout_freq(int fd, double global_lockout_freq)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "ULF,%f", global_lockout_freq);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "ULF,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Lockout Frequency
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int lockout_freq(int fd, double lockout_freq)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "LOF,%f", lockout_freq);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "LOF,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get Close Call Settings
***********************************************************************/
@@ -2292,7 +2487,32 @@
/***********************************************************************
* Set Close Call Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_close_call_settings(int fd, char **parsed_line)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "CLC,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", parsed_line[1],
+ parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5], parsed_line[6],
+ parsed_line[7], parsed_line[8], parsed_line[9], parsed_line[10]);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "CLC,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get Service Search Settings
***********************************************************************/
@@ -2335,7 +2555,32 @@
/***********************************************************************
* Set Service Search Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_service_search_settings(int fd, char **parsed_line)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "SSP,%s,%s,%s,%s,%s,%s,%s,%s", parsed_line[1],
+ parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5], parsed_line[6],
+ parsed_line[7], parsed_line[8]);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "SSP,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get Custom Search Group
***********************************************************************/
@@ -2370,7 +2615,30 @@
/***********************************************************************
* Set Custom Search Group
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_custom_search_group(int fd, char **parsed_line)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "CSG,%s", parsed_line[1]);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "CSG,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get Custom Search Settings
***********************************************************************/
@@ -2411,7 +2679,34 @@
/***********************************************************************
* Set Custom Search Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_custom_search_settings(int fd, int search_index, char **parsed_line)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "CSP,%i, %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", search_index,
+ parsed_line[1], parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5],
+ parsed_line[6], parsed_line[7], parsed_line[8], parsed_line[9], parsed_line[10],
+ parsed_line[11], parsed_line[12], parsed_line[13], parsed_line[14], parsed_line[15],
+ parsed_line[16]);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "CSP,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get Weather Settings
***********************************************************************/
@@ -2446,7 +2741,31 @@
/***********************************************************************
* Set Weather Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_weather_setting(int fd, char **parsed_line)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "WXS,%s,%s,%s,%s", parsed_line[1], parsed_line[2],
+ parsed_line[3], parsed_line[4]);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "WXS,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get Same Group Settings
***********************************************************************/
@@ -2484,7 +2803,32 @@
/***********************************************************************
* Set Same Group Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_same_group_settings(int fd, int same_index, char **parsed_line)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "SGP,%i, %s,%s,%s,%s,%s,%s,%s,%s,%s", same_index,
+ parsed_line[1], parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5],
+ parsed_line[6], parsed_line[7], parsed_line[8], parsed_line[9]);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "SGP,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get Tone-Out Settings
***********************************************************************/
@@ -2523,7 +2867,33 @@
/***********************************************************************
* Set Tone-Out Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_tone_out_settings(int fd, int tone_out_index, char **parsed_line)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "TON,%i, %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", tone_out_index,
+ parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5],
+ parsed_line[6], parsed_line[7], parsed_line[8], parsed_line[9], parsed_line[10],
+ parsed_line[11], parsed_line[12], parsed_line[13], parsed_line[14]);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "TON,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get LCD Contrast Settings
***********************************************************************/
@@ -2558,7 +2928,30 @@
/***********************************************************************
* Set LCD Contrast Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_lcd_contrast_settings(int fd, char **parsed_line)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "CNT,%s", parsed_line[1]);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "CNT,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get LCD Upside Down Settings
***********************************************************************/
@@ -2593,7 +2986,30 @@
/***********************************************************************
* Set LCD Upside Down Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_lcd_upside_down_settings(int fd, char **parsed_line)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "DUD,%s", parsed_line[1]);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "DUD,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get Scanner Option Settings
***********************************************************************/
@@ -2628,23 +3044,152 @@
/***********************************************************************
* Set Scanner Option Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_scanner_option_settings(int fd, char **parsed_line)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "SCN,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s",
+ parsed_line[1], parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5],
+ parsed_line[6], parsed_line[7], parsed_line[8], parsed_line[9], parsed_line[10],
+ parsed_line[11], parsed_line[12], parsed_line[13], parsed_line[14], parsed_line[15],
+ parsed_line[16], parsed_line[17], parsed_line[18], parsed_line[19], parsed_line[20]);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "SCN,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get Volume Level Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int get_volume_level_settings(int fd)
+{
+ char answer[500], command[100];
+ char *field[100];
+ int i;
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+ memset(field, 0, 100);
+
+ snprintf(command, 100, "VOL");
+ /*printf("\nCommand == %s\n", command); */
+ do_command(fd, command, answer);
+ /*printf("%s\n(%i)\n", answer, strlen(answer)); */
+ parse_fields(answer, field);
+
+ /* We have 2 parsed fields to print for this command */
+ for (i = 0; i <= 1; i++)
+ {
+ if (i != 0)
+ printf(",");
+ printf("%s", field[i]);
+ }
+ printf("\n");
+
+ return (0);
+}
+
/***********************************************************************
* Set Volume Level Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_volume_level_settings(int fd, int volume_level)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "VOL,%i", volume_level);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "VOL,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get Squelch Level Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int get_squelch_level_settings(int fd)
+{
+ char answer[500], command[100];
+ char *field[100];
+ int i;
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+ memset(field, 0, 100);
+
+ snprintf(command, 100, "SQL");
+ /*printf("\nCommand == %s\n", command); */
+ do_command(fd, command, answer);
+ /*printf("%s\n(%i)\n", answer, strlen(answer)); */
+ parse_fields(answer, field);
+
+ /* We have 2 parsed fields to print for this command */
+ for (i = 0; i <= 1; i++)
+ {
+ if (i != 0)
+ printf(",");
+ printf("%s", field[i]);
+ }
+ printf("\n");
+
+ return (0);
+}
+
/***********************************************************************
* Set Squelch Level Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_squelch_level_settings(int fd, int squelch_level)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "SQL,%i", squelch_level);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "SQL,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get APCO Data Settings
***********************************************************************/
@@ -2679,11 +3224,39 @@
/***********************************************************************
* Set APCO Data Settings
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_apco_settings(int fd, int threshold)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "P25,%i", threshold);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ /* Uniden's documentation states:
+ "OK" returned when [APCO] is not DFLT
+ "NG" returned when [APCO] is DFLT
+ So, is "int threshold" == [APCO]??? I'll just check for "OK".*/
+ if (strncmp(answer, "P25,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get GPS Display Option
-* TODO: I don't have a GPS. Needs implementing & testing.
+* TODO: I don't have a GPS.
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
int get_gps_display_option(int fd)
{
char answer[500], command[100];
@@ -2714,13 +3287,38 @@
/***********************************************************************
* Set GPS Display Option
-* TODO: I don't have a GPS. Needs implementing & testing.
+* TODO: I don't have a GPS.
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
+int set_gps_display_option(int fd, char **parsed_line)
+{
+ char answer[100], command[500];
+ memset(answer, 0, 500);
+ memset(command, 0, 100);
+
+ snprintf(command, 500, "GDO,%s,%s,%s,%s,%s", parsed_line[1],
+ parsed_line[2], parsed_line[3], parsed_line[4], parsed_line[5]);
+ printf("\nCommand == %s\n", command);
+ do_command(fd, command, answer);
+ printf("%s\n(%i)\n", answer, strlen(answer));
+
+ check_err(command, answer);
+
+ if (strncmp(answer, "GDO,OK", 6) != 0)
+ {
+ exit_prg_mode(fd);
+ u_err(command, answer);
+ }
+
+ return (0);
+}
+
/***********************************************************************
* Get GGA Data from GPS
-* TODO: I don't have a GPS. Needs implementing & testing.
+* TODO: I don't have a GPS.
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
int get_gps_gga_data(int fd)
{
char answer[100], command[100];
@@ -2751,8 +3349,9 @@
/***********************************************************************
* Get RMC Data from GPS
-* TODO: I don't have a GPS. Needs implementing & testing.
+* TODO: I don't have a GPS.
***********************************************************************/
+/* TODO: This needs to be implemented & tested */
int get_gps_rmc_data(int fd)
{
char answer[100], command[100];
@@ -2814,7 +3413,6 @@
/***********************************************************************
* Download BCD memory contents
-* TODO: All done except misc stuff (see commands.h for commented code)
* TODO: Need to also make things look nice.
***********************************************************************/
int dump(int fd, FILE * outfile)
Modified: src/commands.h
===================================================================
--- src/commands.h 2007-11-11 21:28:54 UTC (rev 141)
+++ src/commands.h 2007-11-12 22:07:47 UTC (rev 142)
@@ -38,40 +38,43 @@
/***********************************************************************
* Function Declarations
- * TODO: Finish implementing commented-out functions below
* TODO: Future frontend work might need return of entire parsed_fields
* instead of just printing (ie. to stdout/file) and returning
* nothing. Hence, these also might become installed libraries.
***********************************************************************/
+
+/* Remote Control (Status Display) */
void get_current_tgid_status(int fd);
int push_key(int fd, char key_code, char key_mode);
int quick_search_hold_mode(int fd, char **parsed_line);
void get_current_status(int fd);
void get_reception_status(int fd);
+
+/* System Information */
void get_model_info(int fd);
void get_firmware_version(int fd);
+/* Program Control Mode */
int enter_prg_mode(int fd);
int exit_prg_mode(int fd);
+/* System Settings (Available in Program Mode Only) */
int get_backlight(int fd);
int set_backlight(int fd, char **parsed_line);
-
int clear_memory(int fd);
-
int get_key_beep(int fd);
int set_key_beep(int fd, char **parsed_line);
-
int get_opening_message(int fd);
int set_opening_message(int fd, char **parsed_line);
-
int get_priority_mode(int fd);
int set_priority_mode(int fd, char **parsed_line);
int get_auto_gain_control(int fd);
int set_auto_gain_control(int fd, char **parsed_line);
+int get_system_count(int fd);
-
-/* Scan Settings - Goes in order we get/set - Calls Group Index only once instead of twice */
+/* Scan Settings (Available in Program Mode Only)
+ Goes in order we get/set except for call to
+ "Group Index" is only called once instead of twice. */
int get_system_count(int fd);
int get_system_index_head(int fd);
int get_system_index_tail(int fd);
@@ -108,7 +111,6 @@
int set_apco25_band_plan(int fd, int site_index, char **parsed_line);
int get_trunk_freq_info(int fd, int channel_index);
int set_trunk_freq_info(int fd, int channel_index, char **parsed_line);
-/* End Scan Settings Commands */
int get_lockout_tgid(int fd, int system_index);
@@ -119,58 +121,67 @@
int forward_index(int fd, int index);
int get_remains_memory_block(int fd);
int get_memory_used(int fd);
+
+/* Location Settings (Available in Program Mode Only) */
int loc_alert_system_index_head(int fd, char *loc_alert_system_type);
int get_loc_alert_system_index_tail(int fd, char *loc_alert_system_type);
-/*int create_loc_alert_system(int fd, char *loc_alert_system_type);
-int delete_loc_alert_system(int loc_alert_system_index);*/
+int create_loc_alert_system(int fd, char *loc_alert_system_type);
+int delete_loc_alert_system(int fd, int loc_alert_system_index);
int get_loc_alert_system_info(int fd, int loc_alert_system_index);
-/*int set_loc_alert_system_info(int fd, int loc_alert_system_index, char **parsed_line);*/
+int set_loc_alert_system_info(int fd, int loc_alert_system_index, char **parsed_line);
+
+/* Search/Close Call Settings (Available in Program Mode Only) */
int get_srch_cc_settings(int fd);
-/*int set_srch_cc_settings(int fd, char **parsed_line);*/
+int set_srch_cc_settings(int fd, char **parsed_line);
int get_bcast_screen_band_settings(int fd);
-/*int set_bcast_screen_band_settings(int fd, int bcast_screen_band_settings_index, char **parsed_line);*/
+int set_bcast_screen_band_settings(int fd, int bcast_screen_band_settings_index, char **parsed_line);
int get_search_key_settings(int fd);
-/*int set_search_key_settings(int fd, char **parsed_line); */
+int set_search_key_settings(int fd, char **parsed_line);
int get_global_lockout_freq(int fd);
-/* int unlock_global_lockout_freq(int fd, double global_lockout_freq);
-int lock_out_freq(int fd, double frequency);*/
+int unlock_global_lockout_freq(int fd, double global_lockout_freq);
+int lockout_freq(int fd, double lockout_freq);
int get_close_call_settings(int fd);
-/*int set_close_call_settings(int fd, char **parsed_line);*/
+int set_close_call_settings(int fd, char **parsed_line);
+
+/* Misc (Available in Program Mode Only) */
int get_service_search_settings(int fd);
-/*int set_service_search_settings(int fd, int search_index, char **parsed_line);*/
+int set_service_search_settings(int fd, char **parsed_line);
int get_custom_search_group(int fd);
-/*int set_custom_search_group(int fd, char **parsed_line);*/
+int set_custom_search_group(int fd, char **parsed_line);
int get_custom_search_settings(int fd);
-/*int set_custom_search_settings(int fd, int search_index, char **parsed_line);*/
+int set_custom_search_settings(int fd, int search_index, char **parsed_line);
int get_weather_settings(int fd);
-/*int set_weather_setting(int fd, char **parsed_line);*/
+int set_weather_setting(int fd, char **parsed_line);
int get_same_group_settings(int fd);
-/*int set_same_group_settings(int fd, int same_index, char **parsed_line);*/
+int set_same_group_settings(int fd, int same_index, char **parsed_line);
int get_tone_out_settings(int fd);
-/*int set_tone_out_settings(int fd, int tone_out_index, char **parsed_line);*/
+int set_tone_out_settings(int fd, int tone_out_index, char **parsed_line);
int get_lcd_contrast_settings(int fd);
-/*int set_lcd_contrast_settings(int fd, char **parsed_line);*/
+int set_lcd_contrast_settings(int fd, char **parsed_line);
int get_lcd_upside_down_settings(int fd);
-/*int set_lcd_upside_down_settings(int fd, char **parsed_line);*/
+int set_lcd_upside_down_settings(int fd, char **parsed_line);
int get_scanner_option_settings(int fd);
-/*int set_scanner_option_settings(int fd, char **parsed_line);
+int set_scanner_option_settings(int fd, char **parsed_line);
+
+/* Misc (Use not restricted to Program Mode) */
int get_volume_level_settings(int fd);
int set_volume_level_settings(int fd, int volume_level);
int get_squelch_level_settings(int fd);
-int set_squelch_level_settings(int fd, int squelch_level);*/
+int set_squelch_level_settings(int fd, int squelch_level);
int get_apco_settings(int fd);
-/*int set_apco_settings(int fd, char **parsed_line);*/
+int set_apco_settings(int fd, int threshold);
+/* GPS Related (Available in Program Mode Only) */
+/* (Not Tested. I don't have a GPS for this scanner) */
+int get_gps_display_option(int fd);
+int set_gps_display_option(int fd, char **parsed_line);
-/* GPS Related -- I don't have a GPS for this scanner */
-int get_gps_display_option(int fd);
-/*int set_gps_display_option(int fd, char **parsed_line);*/
-int get_gps_gga_data(int fd); /* TODO: Untested! */
-int get_gps_rmc_data(int fd); /* TODO: Untested! */
+/* GPS Related (Use not restricted to Program Mode) */
+int get_gps_gga_data(int fd);
+int get_gps_rmc_data(int fd);
int get_window_voltage(int fd);
-
-/* Undocumented Uniden Firmware Mode Commands */
+/* Undocumented Uniden Firmware Mode Commands (Available in Program Mode Only) */
int fw_mode_model_info(int fd, char *fwm_model);
int fw_mode_set_speed(int fd, char *fwm_speed);
int fw_mode_pgl(int fd, int pgl_value);
@@ -178,8 +189,7 @@
int fw_mode_scb(int fd, int scb_value);
int fw_mode_program(int fd);
-
-/* Higher Level Functions using above lower level scanner commands */
+/* Higher-level Functions using above Lower-level Scanner Commands */
int dump(int fd, FILE *outfile);
int load_firmware(int fd, FILE *infile);
int load(int fd, FILE *infile);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|