Exemple #1
0
void TTY_Enable(int handle)
{
	ComPort	*p;

	p = handleToPort [handle];
	if (p->enabled)
		return;

	ComPort_Enable(p);

	if (p->useModem && !p->modemInitialized)
		Modem_Init (p);
}
Exemple #2
0
void modem_flush_frame(void) {
	phase_delta = PHASE_DELTA_1200;
	phase = 0;
	packet_pos = 0;
	current_sample_in_baud = 0;

	if(gpsIsOn())
		GPS_hibernate_uart();				// Hibernate UART because it would interrupt the modulation
	Modem_Init();							// Initialize timers and radio

	while(modem_busy())						// Wait for radio getting finished
		__WFI();

	radioShutdown();						// Shutdown radio
	if(gpsIsOn())
		GPS_wake_uart();					// Init UART again to continue GPS decoding
}
Exemple #3
0
void Com_f (void)
{
	ComPort	*p;
	int		portNumber;
	int		i;
	int		n;

	// first, determine which port they're messing with
	portNumber = Q_atoi(Cmd_Argv (0) + 3) - 1;
	if (portNumber > 1)
		return;
	p = handleToPort[portNumber];

	if (Cmd_Argc() == 1)
	{
		Con_Printf("Settings for COM%i\n", portNumber + 1);
		Con_Printf("enabled:   %s\n", p->enabled ? "true" : "false");
		Con_Printf("uart:      ");
		if (p->uartType == UART_AUTO)
			Con_Printf("auto\n");
		else if (p->uartType == UART_8250)
			Con_Printf("8250\n");
		else
			Con_Printf("16550\n");
		Con_Printf("port:      %x\n", p->uart);
		Con_Printf("irq:       %i\n", p->irq);
		Con_Printf("baud:      %i\n", 115200 / p->baudBits);	
		Con_Printf("CTS:       %s\n", (p->modemStatusIgnore & MSR_CTS) ? "ignored" : "honored");
		Con_Printf("DSR:       %s\n", (p->modemStatusIgnore & MSR_DSR) ? "ignored" : "honored");
		Con_Printf("CD:        %s\n", (p->modemStatusIgnore & MSR_CD) ? "ignored" : "honored");
		if (p->useModem)
		{
			Con_Printf("type:      Modem\n");
			Con_Printf("clear:     %s\n", p->clear);
			Con_Printf("startup:   %s\n", p->startup);
			Con_Printf("shutdown:  %s\n", p->shutdown);
		}
		else
			Con_Printf("type:      Direct connect\n");

		return;
	}


	if (Cmd_CheckParm ("disable"))
	{
		if (p->enabled)
			ComPort_Disable(p);
		p->modemInitialized = false;
		return;
	}

	if (Cmd_CheckParm ("reset"))
	{
		ComPort_Disable(p);
		ResetComPortConfig (p);
		return;
	}

	if ((i = Cmd_CheckParm ("port")) != 0)
	{
		if (p->enabled)
			{
				Con_Printf("COM port must be disabled to change port\n");
				return;
			}
		p->uart = Q_atoi (Cmd_Argv (i+1));
	}

	if ((i = Cmd_CheckParm ("irq")) != 0)
	{
		if (p->enabled)
			{
				Con_Printf("COM port must be disabled to change irq\n");
				return;
			}
		p->irq = Q_atoi (Cmd_Argv (i+1));
	}

	if ((i = Cmd_CheckParm ("baud")) != 0)
	{
		if (p->enabled)
			{
				Con_Printf("COM port must be disabled to change baud\n");
				return;
			}
		n = Q_atoi (Cmd_Argv (i+1));
		if (n == 0)
			Con_Printf("Invalid baud rate specified\n");
		else
			p->baudBits = 115200 / n;
	}

	if (Cmd_CheckParm ("8250"))
	{
		if (p->enabled)
			{
				Con_Printf("COM port must be disabled to change uart\n");
				return;
			}
		p->uartType = UART_8250;
		}
	if (Cmd_CheckParm ("16550"))
	{
		if (p->enabled)
			{
				Con_Printf("COM port must be disabled to change uart\n");
				return;
			}
		p->uartType = UART_16550;
	}
	if (Cmd_CheckParm ("auto"))
	{
		if (p->enabled)
			{
				Con_Printf("COM port must be disabled to change uart\n");
				return;
			}
		p->uartType = UART_AUTO;
	}

	if (Cmd_CheckParm ("pulse"))
		p->dialType = 'P';
	if (Cmd_CheckParm ("tone"))
		p->dialType = 'T';

	if (Cmd_CheckParm ("direct"))
		p->useModem = false;
	if (Cmd_CheckParm ("modem"))
		p->useModem = true;

	if ((i = Cmd_CheckParm ("clear")) != 0)
	{
		Q_strncpy (p->clear, Cmd_Argv (i+1), 16);
	}

	if ((i = Cmd_CheckParm ("startup")) != 0)
	{
		Q_strncpy (p->startup, Cmd_Argv (i+1), 32);
		p->modemInitialized = false;
	}

	if ((i = Cmd_CheckParm ("shutdown")) != 0)
	{
		Q_strncpy (p->shutdown, Cmd_Argv (i+1), 16);
	}

	if (Cmd_CheckParm ("-cts"))
	{
		p->modemStatusIgnore |= MSR_CTS;
		p->modemStatus |= MSR_CTS;
	}

	if (Cmd_CheckParm ("+cts"))
	{
		p->modemStatusIgnore &= (~MSR_CTS);
		p->modemStatus = (inportb (p->uart + MODEM_STATUS_REGISTER) & MODEM_STATUS_MASK) | p->modemStatusIgnore;
	}

	if (Cmd_CheckParm ("-dsr"))
	{
		p->modemStatusIgnore |= MSR_DSR;
		p->modemStatus |= MSR_DSR;
	}

	if (Cmd_CheckParm ("+dsr"))
	{
		p->modemStatusIgnore &= (~MSR_DSR);
		p->modemStatus = (inportb (p->uart + MODEM_STATUS_REGISTER) & MODEM_STATUS_MASK) | p->modemStatusIgnore;
	}

	if (Cmd_CheckParm ("-cd"))
	{
		p->modemStatusIgnore |= MSR_CD;
		p->modemStatus |= MSR_CD;
	}

	if (Cmd_CheckParm ("+cd"))
	{
		p->modemStatusIgnore &= (~MSR_CD);
		p->modemStatus = (inportb (p->uart + MODEM_STATUS_REGISTER) & MODEM_STATUS_MASK) | p->modemStatusIgnore;
	}

	if (Cmd_CheckParm ("enable"))
	{
		if (!p->enabled)
			ComPort_Enable(p);
		if (p->useModem && !p->modemInitialized)
			Modem_Init (p);
	}
}