Beispiel #1
0
static FlowMan_Flow Open_m (
        FlowMan_cl      *self,
        string_t        ifname  /* IN */,
        const Netif_TXQoS       *txqos  /* IN */,
        Netif_TXSort    sort /* IN */,
   /* RETURNS */
        IOOffer_clp    *rxoffer,
        IOOffer_clp    *txoffer )
{
    flowman_st	*st = self->st;
    flow_t	*f;
    intf_st	*ifst;

    ifst = ifname2ifst(st->host, ifname);
    if (!ifst)
	return 0;

    f = Heap$Malloc(Pvs(heap), sizeof(*f));
    if (!f)
    {
	printf("FlowMan$Open: out of memory\n");
	return 0;
    }

    /* no data connections as yet */
    f->conns = NULL;
    /* remember which interface this flow is through */
    f->intf = ifst;
    /* no transmit filter as yet */
    f->txpf = NULL;

    /* Get IO channels from device driver */
    TRY {
	f->txoff = Netif$AddTransmitter(ifst->card->netif, txqos, sort, 
					&f->txhdl);
	f->rxoff = Netif$AddReceiver(ifst->card->netif, &f->rxhdl);
    } CATCH_ALL {
	free(f);
	RERAISE;
    }
    ENDTRY;

    /* link onto the flow list for this client */
    f->next = st->flows;
    st->flows = f;

    /* return the whole shebang */
    *rxoffer = f->rxoff;
    *txoffer = f->txoff;
    return (FlowMan_Flow)f;
}
Beispiel #2
0
// Create the transmitter (for when calling the default constructor)
void SCtransmitter::Create(uint8_t pin){
  //check if initialized - set only once
  if(_initialized)
    return;
  
  //add to the Transmitters list
  if(!AddTransmitter(this))
    return;
  
  _initialized = 1;
  
  _pin = pin; //set pin
  pinMode(_pin, OUTPUT); //set as output
  _id = 0;
  _channel = SC_DEFAULT_CHANNEL; //set channel
  _state = SC_STATE_IDLE;
  _start_duration_high = SC_DEFAULT_START_DURATION_HIGH;
  _start_duration_low = SC_DEFAULT_START_DURATION_LOW;
  _duration_high = SC_DEFAULT_DURATION_HIGH;
  _duration_low = SC_DEFAULT_DURATION_LOW;
  _buffer_length = 0;
  digitalWrite(_pin, LOW); //send idle value
}