Exemplo n.º 1
0
upm_result_t rn2903_set_flow_control(const rn2903_context dev,
                                     RN2903_FLOW_CONTROL_T fc)
{
    assert(dev != NULL);

    mraa_result_t rv = MRAA_SUCCESS;

    switch(fc)
    {
    case RN2903_FLOW_CONTROL_NONE:
        rv = mraa_uart_set_flowcontrol(dev->uart, false, false);
        break;

    case RN2903_FLOW_CONTROL_HARD:
        rv = mraa_uart_set_flowcontrol(dev->uart, false, true);
        break;

    default:
        return UPM_ERROR_INVALID_PARAMETER;
    }

    if (rv == MRAA_SUCCESS)
        return UPM_SUCCESS;
    else
        return UPM_ERROR_OPERATION_FAILED;
}
Exemplo n.º 2
0
Arquivo: ecezo.c Projeto: g-vidal/upm
// uart init
ecezo_context ecezo_uart_init(unsigned int uart, unsigned int baudrate)
{
    // make sure MRAA is initialized
    int mraa_rv;
    if ((mraa_rv = mraa_init()) != MRAA_SUCCESS)
    {
        printf("%s: mraa_init() failed (%d).\n", __FUNCTION__, mraa_rv);
        return NULL;
    }

    ecezo_context dev =
        (ecezo_context)malloc(sizeof(struct _ecezo_context));

    if (!dev)
        return NULL;

    // zero out context
    memset((void *)dev, 0, sizeof(struct _ecezo_context));

    // initialize the MRAA contexts

    // uart, default should be 8N1
    if (!(dev->uart = mraa_uart_init(uart)))
    {
        printf("%s: mraa_uart_init() failed.\n", __FUNCTION__);
        ecezo_close(dev);
        return NULL;
    }

    if (mraa_uart_set_baudrate(dev->uart, baudrate))
    {
        printf("%s: mraa_uart_set_baudrate() failed.\n", __FUNCTION__);
        ecezo_close(dev);
        return NULL;
    }

    mraa_uart_set_flowcontrol(dev->uart, false, false);

    if (generic_init(dev))
    {
        printf("%s: generic_init() failed.\n", __FUNCTION__);
        ecezo_close(dev);
        return NULL;
    }

    return dev;
}
Exemplo n.º 3
0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////	Modem related functions		//////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int init_modem(){
	mraa_init();
	 if( (uart = mraa_uart_init(0)) == NULL   ){
	   		writeToFile(src, "error INITIATING UART\n");
  			exit(UART_ERROR);
	 }
	 /*set uart boud rate [bps]*/
	 if ( mraa_uart_set_baudrate(uart, UART_BOUD_RATE)!=MRAA_SUCCESS) {
  		writeToFile(src, "error seting baudrate\n");
  		exit(UART_ERROR);
  		}		
  if ( mraa_uart_set_mode(uart, 8,MRAA_UART_PARITY_NONE , 1)!=MRAA_SUCCESS) {
  writeToFile(src, "error seting mode\n");
	}
	mraa_uart_set_flowcontrol(uart, 0, 0);
	writeToFile(src, "init modem\n");	
}
Exemplo n.º 4
0
Arquivo: uart.hpp Projeto: emutex/mraa
 /**
  * Set the flowcontrol
  *
  * @param xonxoff XON/XOFF Software flow control.
  * @param rtscts RTS/CTS out of band hardware flow control
  * @return Result of operation
  */
 Result
 setFlowcontrol(bool xonxoff, bool rtscts)
 {
     return (Result) mraa_uart_set_flowcontrol(m_uart, xonxoff, rtscts);
 }