/* icom.c frajr 02-28-89 I have an Icom-735 and have been messing around with the RS-232 interface. There are a few text files with information about how to build an interface for the Icom RS-232 connection. I found two on Compuserve in the HAMNET SWL section. If you don't hve access to Compuserve, and or can't find information I'll try to send replies to an SASE. This short function simple monitors the data that comes from the ICOM RS232 interface all the time, wheither you want it or not. Type Icom to start the small monitor program. A station ID file is opened on drive a: during the start of the file. I have some desire to collect data, either QSL info or latitude, longitude, satellite parameters, etc in the future. A disk must be in the A: drive for the program to run. Pressing enter will kill the program and close the station ID file. Using the same disk the next time will prevent being asked for the callsign. It is read from the disk. Obviously not a major step forward and not a major program. I'm only playing with some functions learning how to use the ICOM interface. I someone needs something particular, please write and/or call. It might not get done but at least I'll know what you need! F.R. Allen KA1QW P.O. Box 25 N. Waterboro ME. 04061-0025 nights around 24.978 Mhz */ #include #include #include #include #include #define NODATA 1 FILE *icom; /* new log data coming in */ char callsign[7]; struct unit { char callsign[7]; char name[20]; char qth[20]; char state[2]; }; struct unit station; int freq[10]; /* frequency being received */ int stat_and_char; int x; int set; int packet[128]; int mode_count = 0; main() { extern int freq[10]; /* frequency being received */ extern int stat_and_char; extern int x; extern int set; extern int packet[128]; extern int mode_count; int y; /* print out packet characters */ int screen_error; /* if error drawing to screen */ int numofpacket = 0; int length; int answer = 'n'; int menu = 'a'; int rs232_error; /* asynch error code returned */ long dd; /* clear the screen and place the cursor at line 5 column 10 */ _clearscreen(_GCLEARSCREEN); _settextposition(4,5); _settextposition(7,5); /* make sure a disk is in drive a: */ printf("Do you have a formatted disk in drive a: ?"); while (answer = getch() != 'y') { answer = getch(); } /* if there is NOT a file named icom.dat on the disk then create one */ /* if there is a file on drive a: named icom.dat then open it */ if ( ( icom = fopen("a:icom.dat","r")) == NULL) { get_station_data(NODATA); } /* open the RS-232 port for 1200 baud 1 stop 8 data bits this is the default for Icom radios as shipped It needs to be set to 9600 for good operation but 1200 will do for this program. */ rs232_error = async_open( 1 , "1200N81" , 750 , 750 ); if ( rs232_error == R_NOPORT ) { _settextposition(20,5); printf("COM1 not available on your system"); exit(0); } _setvideomode(_HRESBW); _clearscreen(_GCLEARSCREEN); _setcolor(_BRIGHTWHITE); _rectangle(_GBORDER,10,10,610,190); _settextposition(2,20); _outtext("KA1QW Icom-735 Interface version 1.10 3-06-89"); set = 0 ; setupmode(); /* USB */ setupicom(); /* vfo a */ for (x = 5 ; x <= 20 ; x=x+5) { setwwv(x); for (dd = 0 ; dd <= 300000; dd++); } setupmode(); setinitialfreq(); /* 24,978.0 */ _settextposition(3,5); printf("Receiver : ",freq[0]); _settextposition(3,25); printf("VFO A"); _settextposition(3,55); printf("VFO B"); /* this is the start of the routine to service the data from the ICOM It is really just a big loop to read a character from the RS-232 make a decision about what it it and where it goes, and print it on the screen. */ while (1) { if (kbhit()) { menu = getch(); selection(menu); } stat_and_char = async_rx(1); get_data(); } } /* -------------------------------------------------------------------------- PASSED :number identifying who called - not used here RETURNS :status of operation 0 if OK non zero if not OK DATE :02-25-89 -------------------------------------------------------------------------- */ int get_station_data(caller) int caller; { extern FILE *icom; extern char callsign[]; extern int mode_count; int result; if ( ( icom = fopen("a:icom.dat","a")) == NULL) { exit(0); } _clearscreen(_GCLEARSCREEN); _rectangle(_GBORDER,10,10,610,190); _settextposition(15,5); _outtext("Type your callsign :"); result = scanf("%s",station.callsign); fprintf(icom,"%s",station.callsign); fflush(icom); fclose(icom); return; } /* end of get_station_data */ setupicom() { async_tx(1,0xFE); async_tx(1,0xFE); async_tx(1,0x4); async_tx(1,0xF1); async_tx(1,0x7); async_tx(1,0x0); async_tx(1,0xFD); } setupmode() { async_tx(1,0xFE); async_tx(1,0xFE); async_tx(1,0x4); async_tx(1,0xF2); async_tx(1,0x1); async_tx(1,0x1); async_tx(1,0xFD); } setinitialfreq() { async_tx(1,0xFE); async_tx(1,0xFE); async_tx(1,0x4); async_tx(1,0xF1); async_tx(1,0x0); async_tx(1,0x00); async_tx(1,0x80); async_tx(1,0x97); async_tx(1,0x24); async_tx(1,0xFD); } int selection(menu) int menu; { int rs232_error; /* asynch error code returned */ switch (menu) { case 'q': case 'Q': printf("Closing the rs232 out to com1"); rs232_error = async_close(1); _setvideomode(_DEFAULTMODE); exit(2); case 'a': case 'A': break; case 'm': /* install memory to vfo */ case 'M': break; case 's': /* scan the memories */ case 'S': break; case 'v': /* scan the VFO limits */ case 'V': break; case 'C': /* change memory in Icom */ case 'c': break; default: break; } } /* -------------------------------------------------------------------------- getdata PASSED :NOTHING RETURNS :Zero (0) if OK non zero if NOT OK _settextposition(3,5); printf("Receiver : ",freq[0]); DATE : 03--5-89 -------------------------------------------------------------------------- */ int get_data(void) { extern int freq[]; extern int stat_and_char; extern int mode_count; extern int set; extern int x; if (stat_and_char == 0xFE && set != 0) { if (set == 1) { set = 2; } if (set == 2) { if (freq[1] == 0x01) { _settextposition(6,35); printf("Control Code :%x",freq[1]); printf(" "); _settextposition(20,10); switch (freq[2]) { case 0: printf("LSB"); break; case 1: printf("USB"); break; case 2: printf("AM"); break; case 3: printf("CW"); break; case 4: printf("RTTY"); break; case 5: printf("FM"); break; default: break; } } if (freq[1] == 0x04) { _settextposition(7,70); printf(" %x",freq[2]); } if (freq[1] != 0x04) { _settextposition(4,20); for (x = 5 ; x >= 2; x--) { switch (x) { case 5: printf("%x.",freq[x]); break; case 4: if (freq[x] >= 0 && freq[x] <= 9) { printf("0"); } printf("%x ",freq[x]); break; case 3: if (freq[x] >= 0 && freq[x] <= 9) { printf("0"); } printf("%x ",freq[x]); break; case 2: if (freq[x] >= 0 && freq[x] <= 9) { printf("0"); } printf("%x ",freq[x]); break; case 1: if (freq[x] >= 0 && freq[x] <= 9) { printf("0"); } printf("%x ",freq[x]); break; default: break; } } } x = 0; } } if (stat_and_char == 0xFD) { set = 0; } if (stat_and_char != 0x4000 && set == 2) { if (x >= 2) { freq[x-2] = stat_and_char; } x++; } if (stat_and_char == 0xFE && set == 0) { set = 1; } } int setwwv(x) int x; { async_tx(1,0xFE); async_tx(1,0xFE); async_tx(1,0x4); async_tx(1,0xF2); async_tx(1,0x1); async_tx(1,0x2); async_tx(1,0xFD); async_tx(1,0xFE); async_tx(1,0xFE); async_tx(1,0x4); async_tx(1,0xF1); async_tx(1,0x0); async_tx(1,0x00); async_tx(1,0x10); async_tx(1,0x00); async_tx(1,0x20); async_tx(1,0xFD); }