Ok, it seems that we are back where we started from talking about the RSS_IOP. There have been so many changes that we may as well just start over.
So now I can share with you the major data structures from here forward. So lets get started.
| rss and tuner | radio_xxxxx |
|---|---|
typedef enum _Radio_Types { G3717, C614L8, G1981, G3490, G4214 }Radio_Types;
struct rss_s { char * device_info; // some thing about the radio NAV/COM/etc. char * device_model; // the Manufactures part/model number. char * device_serial; // the device's serial number.. Radio_Types device_type; // Its device_type which is defined by the typedef above Radio_Types int power_48v; // power to the unit.. int power_400hz; int panel_lamps; // turn off or on the Panel Lamps only void * radio_info; void * tuner; int sub_devices; // how many tuners are in this device. };
enum fd_index { RD, WR, FD_pair };
typedef enum _tuned_units { // this is for numbers that have the form of nnn.ff (n= number) (f= fractions) hundreds, tens, units, tenths, hundredths, tuned }tuned_units;
typedef struct tuner_s { // when we talk about 'sub-radios' we are really saying how many tuners are there?? int power; int dial_lamp; char * device_name; // OS-name int fd[ FD_pair ]; // file descriptors int frequency[ tuned_units ]; }tuner; | // This is for the Collins G14L8 Adf head. typedef enum _mode_sw_614L8 { OFF = 0, ADF, ANT, LOOP }mode_sw614L8;
typedef enum _loop_sw_614L8 { LEFT, RIGHT, SLEW_LEFT, SLEW_RIGHT, }loop_sw614L8;
struct radio_s_614L8 { loop_sw614L8 loop_sw_614L8; mode_sw614L8 mode_sw_614L8; int sw_band; int sw_bfo; int meter; };
//// G1981 ATC Transponder // As the ATC Transponder does not have a tuner // we can ignore the field 'int frequency[ tuned ];'
typedef enum _mode_sw_G1981 { STBY, ON, LOW, mode_swG1981 }mode_sw_G1981;
typedef enum _band_sw_G1981 { band_A, band_B, band_C, band_D, band_swG1981 }band_sw_G1981;
struct radio_s_G1981 { mode_sw_G1981 mode_switch; band_sw_G1981 band_switch; int sw_ATC; int sw_ident; int test_monitor; int alt_off; int squawk[ 4 ]; };
//// G-3717 this is a simple radio with 2 tuners.
struct radio_s_G3717 { int sw_VHF_NAV; int sw_VOR_TEST; int sw_DME_TEST; int sw_DME_STBY; int sw_UP; int sw_DOWN; }; |
| main.c |
|---|
#include <stdio.h>
#include "rss.h" #include "main.h" #include "rss_init.h"
int main(int argc, char *argv[]){
max_fd = 0; int ecode; // bus voltages int p400; int p48;
// The Radio Tuners // ** Please note the "dev/stuff is not right and must be changed before testing.
static struct tuner tuner_G_3717[] = { { 0, 0, "/dev/tty0/usb1", }, { 0, 0, "/dev/tty0/usb1", } }; static struct tuner tuner_C_614L8[] = { { 0, 0, "/dev/tty0/usb1", }}; static struct tuner tuner_G_1981[] = { { 0, 0, "/dev/tty0/usb1", }}; static struct tuner tuner_G_4214[] = { { 0, 0, "/dev/tty0/usb1", }}; static struct tuner tuner_G_3490[] = { { 0, 0, "/dev/tty0/usb1", }, { 0, 0, "/dev/tty0/usb1", }, { 0, 0, "/dev/tty0/usb1", }, { 0, 0, "/dev/tty0/usb1", }};
// The Radio Details static struct radio_s_G3713 radio_G_3713 = { { 0, 0, 0, 0, 0, 0 }}; static struct radio_s_614L8 radio_C_614L8 = { { 0, 0, 0, 0, 0 }}; static struct radio_s_G1981 radio_G_1981 = { { 0, 0, 0, 0, 0, 0, {0}}}; static struct radio_s_G3490 radio_G_3490 = { { 0, 0, 0, 0, 0, 0, 0 }}; static struct radio_s_G4214 radio_G_4214 = { { 0 }};
// The Radio(s) Master List
static struct rss_s radios[] = { { "COM 1 & 2", "G-4214", "68", G4214, 0, 0, 0, & radio_G_4214, tuner_G_4214, DIM( tuner_G_4214 ) }, { "VOR, DME", "G-3717", "81", G3717, 0, 0, 0, & radio_G_3713, tuner_G_3713, DIM( tuner_G_3713 ) }, { "ADF", "614L8", "8384", C614L8, 0, 0, 0, & radio_C_614L8, tuner_C_614L8, DIM( tuner_C_614L8 ) }, { "ATC", "G-1981", "336", G1981, 0, 0, 0, & radio_G_1981, tuner_G_1981, DIM( tuner_G_1981 ) }, { "5in1", "G-3490", "31", G3490, 0, 0, 0, & radio_G_3490, tuner_G_3490, DIM( tuner_G_3490 ) }, // Optional Radio };
int i, j; // loop over the installed Radios and sub radios for( i = 0; i < DIM( radios ); i++ ){ if( rss_init( & radios[ i ] ) == ERROR ){ perror( "Initialization failed"); return( ERROR ); } }
do{ ecode = 1; // test for power errors p400 = power_buss_400hz(); p48 = power__buss_48v(); if( p48 != OFF || p400 != OFF ){ ecode = GO;} else { ecode = ERROR; if( !p400 ) error_msg(); if( !p48 ) error_msg(); }
// iop returns with error TBD!!
} while( ecode != ERROR ); } |
So far so good. I have shown you what our data structures are now. I will show you my main.c. You will notice that all of the radio components ie: radio[], tuners, and radios are all declared static, as their "lifetime or extent" extends across the entire run of the program.
~~ Cris.
Apr 14, 2014
Changes just a few:
1) struct radio_614L8 is now struct radio_s_614L8
the radio_s_XXXX is the form that I will be using the _s_ stands for structure
this changes the invocation of the radio in my main.c
from
static struct radio_G3713 radio_G_3713
to
static struct radio_s_G3713 radio_G_3713
2) power testing has been simplified:
if ((( p400 = power_buss_400hz()) || ( p48 = power__buss_48v())) != OFF ){
to
p400 = power_buss_400hz();
p48 = power__buss_48v();
if( p48 != OFF || p400 != OFF ){
