mirror of
https://github.com/MiSTer-devel/MidiLink_MiSTer.git
synced 2026-05-24 03:04:13 +00:00
Merge pull request #10 from bbond007/master
Refactor modem stuff out of main.c to modem.c
This commit is contained in:
2
Makefile
2
Makefile
@@ -3,7 +3,7 @@ STRIP=arm-linux-gnueabihf-strip
|
||||
CCFLAGS=-Ialsa/include -Lalsa/lib -Ofast -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=hard -ftree-vectorize -funsafe-math-optimizations
|
||||
LDFLAGS=-lasound -lm -pthread
|
||||
all :
|
||||
$(CC) $(CCFLAGS) $(LDFLAGS) main.c serial.c serial2.c misc.c udpsock.c tcpsock.c alsa.c ini.c directory.c modem_snd.c -o midilink
|
||||
$(CC) $(CCFLAGS) $(LDFLAGS) main.c modem.c serial.c serial2.c misc.c udpsock.c tcpsock.c alsa.c ini.c directory.c modem_snd.c -o midilink
|
||||
$(STRIP) midilink
|
||||
$(CC) $(CCFLAGS) mlinkutil.c misc.c serial2.c tcpsock.c -o mlinkutil
|
||||
$(STRIP) mlinkutil
|
||||
|
||||
22
config.h
22
config.h
@@ -9,21 +9,20 @@
|
||||
// Thanks to https://ccrma.stanford.edu/~craig/articles/linuxmidi/ for the
|
||||
// excellent MIDI programming examples.
|
||||
//
|
||||
// "/dev/sequencer" does not seem to work for input
|
||||
|
||||
static char * midiLinkINI = "/media/fat/linux/MidiLink.INI";
|
||||
static char * midiLinkDIR = "/media/fat/linux/MidiLink.DIR";
|
||||
static char * serialDevice = "/dev/ttyS1";
|
||||
static char * serialDeviceUSB = "/dev/ttyUSB0";
|
||||
static char * helloStr = "MiSTer MidiLink 2.9d BB7";
|
||||
char * midiLinkINI = "/media/fat/linux/MidiLink.INI";
|
||||
char * midiLinkDIR = "/media/fat/linux/MidiLink.DIR";
|
||||
char * serialDevice = "/dev/ttyS1";
|
||||
char * helloStr = "MiSTer MidiLink 3.0 BB7";
|
||||
char * PCMDevice = "/dev/snd/pcmC0D0p";
|
||||
int CPUMASK = 1;
|
||||
static char * MrAudioDevice = "/dev/MrAudio";
|
||||
static unsigned char test_note[3] = {0x90, 60, 127};
|
||||
static char * midiINDevice = "/dev/midi2";
|
||||
static char * midiDevice = "/dev/midi1";
|
||||
static char * PCMDevice = "/dev/snd/pcmC0D0p";
|
||||
static char * MrAudioDevice = "/dev/MrAudio";
|
||||
static int CPUMASK = 1;
|
||||
|
||||
static char all_notes_off[] =
|
||||
static char * serialDeviceUSB = "/dev/ttyUSB0";
|
||||
|
||||
char all_notes_off[] =
|
||||
{
|
||||
0xb0, 0x7b, 0x00, 0xb0, 0x40, 0x00, 0xb1, 0x7b, 0x00, 0xb1, 0x40, 0x00, 0xb2, 0x7b, 0x00, 0xb2, 0x40, 0x00,
|
||||
0xb3, 0x7b, 0x00, 0xb3, 0x40, 0x00, 0xb4, 0x7b, 0x00, 0xb4, 0x40, 0x00, 0xb5, 0x7b, 0x00, 0xb5, 0x40, 0x00,
|
||||
@@ -33,6 +32,7 @@ static char all_notes_off[] =
|
||||
0xbf, 0x7b, 0x00, 0xbf, 0x40, 0x00
|
||||
};
|
||||
|
||||
int sizeof_all_notes_off = sizeof(all_notes_off);
|
||||
|
||||
|
||||
|
||||
|
||||
2
ini.c
2
ini.c
@@ -321,7 +321,7 @@ void ini_print_settings(int p)
|
||||
misc_print(p, " - FSYNTH_VOLUME --> %d%c\n", fsynthVolume, '%');
|
||||
else
|
||||
misc_print(p, " - FSYNTH_VOLUME --> Default (don't set)\n");
|
||||
if(fsynthVolume != -1)
|
||||
if(modemVolume != -1)
|
||||
misc_print(p, " - MODEM_VOLUME --> %d%c\n", modemVolume, '%');
|
||||
else
|
||||
misc_print(p, " - MODEM_VOLUME --> Default (don't set)\n");
|
||||
|
||||
64
misc.c
64
misc.c
@@ -34,45 +34,6 @@ static pthread_mutex_t swrite_lock;
|
||||
extern int MIDI_DEBUG;
|
||||
extern enum ASCIITRANS TCPAsciiTrans;
|
||||
|
||||
static char * athelp[] =
|
||||
{
|
||||
"AT - Attention",
|
||||
"ATBAUD# - Set baud rate",
|
||||
"ATBAUD - Show baud rate menu",
|
||||
"ATDIR - Show dialing MidiLink.DIR",
|
||||
"ATDT - Dial 'ATDT192.168.1.131:23'",
|
||||
"ATHELP - Show valid AT Comamnds",
|
||||
"ATINI - Show MidiLink.INI",
|
||||
"ATIP - Show IP address",
|
||||
"ATMID1 - Switch synth to FluidSynth",
|
||||
"ATMID2 - Switch synth to MUNT",
|
||||
"ATMID - Play MIDI file",
|
||||
"ATMIDSF - Select FluidSynth SoundFont",
|
||||
"ATMID! - Stop currently playing MIDI",
|
||||
"ATM0 - Disable modem sounds",
|
||||
"ATM1 - Enable modem sounds",
|
||||
"ATM###%% - Set modem volume [0-100%%]",
|
||||
"ATMP3 - Play MP3 file",
|
||||
"ATMP3! - Stop playing MP3 File",
|
||||
"ATROWS - Do terminal row test",
|
||||
"ATROWS## - Set number of terminal rows",
|
||||
"ATRZ - Receive a file using Zmodem",
|
||||
"ATSZ - Send a file via Zmodem",
|
||||
"ATTEL0 - Disable telnet negotiation",
|
||||
"ATTEL1 - Enable telnet negotiation",
|
||||
"ATTRANS# - Set ASCII translation",
|
||||
"ATQ0 - Verbose result codes",
|
||||
"ATQ1 - Suppress result codes",
|
||||
"ATVER - Show MidiLink version",
|
||||
"ATZ - Reset modem",
|
||||
"AT&D0 - DTR mode normal",
|
||||
"AT&D2 - DTR drop causes hangup",
|
||||
"AT&K0 - Disable flow control",
|
||||
"AT&K3 - RTS/CTS flow control",
|
||||
"AT&K4 - XON/XOFF flow control",
|
||||
"+++ATH - Hang-up",
|
||||
NULL
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -434,6 +395,7 @@ int misc_check_module_loaded (char * modName)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// int misc_get_midi_port(char * descr)
|
||||
@@ -477,6 +439,7 @@ int misc_get_midi_port(char * descr)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -842,27 +805,6 @@ void misc_do_rowcheck(int fdSerial, int rows, int * rowcount, char * c)
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// void misc_show_at_commands(int fdSerial, int rows)
|
||||
//
|
||||
void misc_show_at_commands(int fdSerial, int rows)
|
||||
{
|
||||
int index = 0;
|
||||
int rowcount = 0;
|
||||
char c = (char) 0x00;
|
||||
|
||||
while(athelp[index] != NULL && c != 'Q')
|
||||
{
|
||||
misc_swrite(fdSerial, "\r");
|
||||
if (rowcount != 0 || index == 0) //rowcount not reset
|
||||
misc_swrite(fdSerial, "\n");
|
||||
misc_swrite(fdSerial, athelp[index]);
|
||||
index++;
|
||||
misc_do_rowcheck(fdSerial, rows, &rowcount, &c);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BOOL misc_do_pipe2(int fdSerial, char * command)
|
||||
@@ -993,3 +935,5 @@ char * misc_hayes_ATQ_to_str(int dtr)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
70
misc.h
70
misc.h
@@ -1,45 +1,43 @@
|
||||
enum SOFTSYNTH { MUNT, FluidSynth};
|
||||
enum SOFTSYNTH { MUNT, FluidSynth};
|
||||
enum ASCIITRANS { AsciiNoTrans, AsciiToPetskii, AsciiToAtascii};
|
||||
|
||||
int misc_check_args_option (int argc, char *argv[], char * option);
|
||||
int misc_check_args_option (int argc, char *argv[], char * option);
|
||||
char * misc_trans_to_str(enum ASCIITRANS mode);
|
||||
int misc_str_to_trans(char * str);
|
||||
void misc_str_to_upper(char *str);
|
||||
int misc_check_file (char * fileName);
|
||||
int misc_check_device (char * deviceName);
|
||||
int misc_set_priority(int priority);
|
||||
int misc_ipaddr_is_multicast(char * ipAddr);
|
||||
void misc_print(int priority, const char* format, ... );
|
||||
void misc_swrite(int fdSerial, const char* format, ... );
|
||||
void misc_swrite_no_trans(int fdSerial, const char* format, ... );
|
||||
int misc_is_ip_addr(char *ipAddr);
|
||||
int misc_hostname_to_ip(char * hostname , char* ipAddr);
|
||||
int misc_get_ipaddr(char * interface, char * buf);
|
||||
int misc_is_number(char *testStr);
|
||||
void misc_show_atdt(int fdSerial);
|
||||
void misc_show_atip(int fdSerial);
|
||||
long misc_get_timeval_diff(struct timeval * start, struct timeval * stop);
|
||||
int misc_check_module_loaded (char * modName);
|
||||
int misc_get_midi_port(char * descr);
|
||||
int misc_list_files(char * path, int fdSerial, int rows, char * fileName, int * DIR);
|
||||
void misc_d_type_to_str(unsigned char type, char * buf);
|
||||
int misc_file_to_serial(int fdSerial, char * fileName, int rows);
|
||||
int misc_count_str_chr(char * str, char chr);
|
||||
int misc_MT32_LCD(char * MT32Message, char * buf);
|
||||
void misc_show_at_commands(int fdSerial, int rows);
|
||||
void misc_do_rowcheck(int fdSerial, int rows, int * rowcount, char * c);
|
||||
int misc_get_core_name(char * buf, int maxBuf);
|
||||
char misc_replace_char(char * str, int strLen, char old, char new);
|
||||
int misc_do_pipe(int fdSerial, char * path, char * command,
|
||||
char * arg1,
|
||||
char * arg2,
|
||||
char * arg3,
|
||||
char * arg4,
|
||||
char * arg5);
|
||||
int misc_str_to_trans(char * str);
|
||||
void misc_str_to_upper(char *str);
|
||||
int misc_check_file (char * fileName);
|
||||
int misc_check_device (char * deviceName);
|
||||
int misc_set_priority(int priority);
|
||||
int misc_ipaddr_is_multicast(char * ipAddr);
|
||||
void misc_print(int priority, const char* format, ... );
|
||||
void misc_swrite(int fdSerial, const char* format, ... );
|
||||
void misc_swrite_no_trans(int fdSerial, const char* format, ... );
|
||||
int misc_is_ip_addr(char *ipAddr);
|
||||
int misc_hostname_to_ip(char * hostname , char* ipAddr);
|
||||
int misc_get_ipaddr(char * interface, char * buf);
|
||||
int misc_is_number(char *testStr);
|
||||
void misc_show_atdt(int fdSerial);
|
||||
void misc_show_atip(int fdSerial);
|
||||
long misc_get_timeval_diff(struct timeval * start, struct timeval * stop);
|
||||
int misc_check_module_loaded (char * modName);
|
||||
int misc_list_files(char * path, int fdSerial, int rows, char * fileName, int * DIR);
|
||||
void misc_d_type_to_str(unsigned char type, char * buf);
|
||||
int misc_file_to_serial(int fdSerial, char * fileName, int rows);
|
||||
int misc_count_str_chr(char * str, char chr);
|
||||
int misc_MT32_LCD(char * MT32Message, char * buf);
|
||||
void misc_do_rowcheck(int fdSerial, int rows, int * rowcount, char * c);
|
||||
int misc_get_core_name(char * buf, int maxBuf);
|
||||
char misc_replace_char(char * str, int strLen, char old, char new);
|
||||
int misc_do_pipe(int fdSerial, char * path, char * command,
|
||||
char * arg1,
|
||||
char * arg2,
|
||||
char * arg3,
|
||||
char * arg4,
|
||||
char * arg5);
|
||||
char * misc_hayes_flow_to_str(int flow);
|
||||
char * misc_hayes_DTR_to_str(int dtr);
|
||||
char * misc_hayes_ATQ_to_str(int dtr);
|
||||
char * misc_get_clrScr();
|
||||
|
||||
//int misc_get_midi_port(char * descr);
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
19
modem.h
Normal file
19
modem.h
Normal file
@@ -0,0 +1,19 @@
|
||||
void modem_play_connect_sound(char * tmp);
|
||||
void modem_play_ring_sound(char * tmp);
|
||||
void modem_play_dial_sound(char * tmp, char * ipAddr);
|
||||
void modem_do_check_hangup(int * socket, char * buf, int bufLen);
|
||||
void modem_do_telnet_negotiate();
|
||||
int modem_do_file_picker(char * pathBuf, char * fileNameBuf);
|
||||
void modem_do_emulation(char * buf, int bufLen);
|
||||
int modem_handle_at_command(char * lineBuf);
|
||||
void modem_killall_aplay(int delay);
|
||||
void modem_killall_aplaymidi(int delay);
|
||||
void modem_killall_mpg123(int delay);
|
||||
void * modem_tcplst_thread_function (void * x);
|
||||
void * modem_tcpsock_thread_function (void * x);
|
||||
int modem_get_softsynth_port(int softSynth);
|
||||
void modem_set_defaults();
|
||||
void modem_show_at_commands(int fdSerial, int rows);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user