Skip to content

Input support (TXINH so far) #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 3, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Implement TXINH
  • Loading branch information
ab0tj committed Nov 17, 2015
commit d9ca8cdc521e14b58469f589604aac33ce09b99b
4 changes: 4 additions & 0 deletions atest.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,10 @@ void ptt_set (int ot, int chan, int ptt_signal)
return;
}

int get_input (int it, int chan)
{
return -1;
}

static void usage (void) {

Expand Down
6 changes: 5 additions & 1 deletion hdlc_rec.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,13 @@ void dcd_change (int chan, int subchan, int state)

int hdlc_rec_data_detect_any (int chan)
{
int busy = 0;

assert (chan >= 0 && chan < MAX_CHANS);

return (composite_dcd[chan] != 0);
if (composite_dcd[chan] != 0) busy = 1;

if (get_input(ICTYPE_TXINH, chan) == 1) busy = 1;

} /* end hdlc_rec_data_detect_any */

Expand Down
75 changes: 75 additions & 0 deletions ptt.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,21 @@ void ptt_set_debug(int debug)
ptt_debug_level = debug;
}

/*-------------------------------------------------------------------
*
* Name: export_gpio
*
* Purpose: Tell the GPIO subsystem to export a GPIO line for
* us to use, and set the initial state of the GPIO.
*
* Inputs: gpio - GPIO line to export
* invert: - Is the GPIO active low?
* direction: - 0 for input, 1 for output
*
* Outputs: None.
*
*------------------------------------------------------------------*/

void export_gpio(int gpio, int invert, int direction)
{
HANDLE fd;
Expand Down Expand Up @@ -843,7 +858,67 @@ void ptt_set (int ot, int chan, int ptt_signal)

} /* end ptt_set */

/*-------------------------------------------------------------------
*
* Name: get_input
*
* Purpose: Read the value of an input line
*
* Inputs: it - Input type (ICTYPE_TCINH supported so far)
* chan - Audio channel number
*
* Outputs: 0 = inactive, 1 = active, -1 = error
*
* ------------------------------------------------------------------*/

int get_input (int it, int chan)
{
assert (it >= 0 && it < NUM_ICTYPES);
assert (chan >= 0 && chan < MAX_CHANS);

if ( ! save_audio_config_p->achan[chan].valid) {
text_color_set(DW_COLOR_ERROR);
dw_printf ("Internal error, get_input ( %d, %d ), did not expect invalid channel.\n", it, chan);
return -1;
}

#if __WIN32__
#else
if (save_audio_config_p->achan[chan].ictrl[it].method == PTT_METHOD_GPIO) {
int fd;
char stemp[80];

snprintf (stemp, sizeof(stemp), "/sys/class/gpio/gpio%d/value", save_audio_config_p->achan[chan].ictrl[it].gpio);

fd = open(stemp, O_RDONLY);
if (fd < 0) {
int e = errno;
text_color_set(DW_COLOR_ERROR);
dw_printf ("Error opening %s to check input.\n", stemp);
dw_printf ("%s\n", strerror(e));
return -1;
}

char vtemp[2];
if (read (fd, vtemp, 1) != 1) {
int e = errno;
text_color_set(DW_COLOR_ERROR);
dw_printf ("Error getting GPIO %d value\n", save_audio_config_p->achan[chan].ictrl[it].gpio);
dw_printf ("%s\n", strerror(e));
}
close (fd);

if (atoi(vtemp) != save_audio_config_p->achan[chan].ictrl[it].invert) {
return 1;
}
else {
return 0;
}
}
#endif

return -1; /* Method was none, or something went wrong */
}

/*-------------------------------------------------------------------
*
Expand Down
1 change: 1 addition & 0 deletions ptt.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void ptt_set (int octype, int chan, int ptt);

void ptt_term (void);

int get_input (int it, int chan);

#endif

Expand Down