Ejemplo n.º 1
0
void
test_port_config(void) {
    datastore_bridge_info_t info;
    struct ofp_port_mod port_mod;
    struct ofp_error error;
    struct bridge *bridge;
    lagopus_result_t rv;

    memset(&info, 0, sizeof(info));
    info.fail_mode = DATASTORE_BRIDGE_FAIL_MODE_SECURE;
    TEST_ASSERT_EQUAL(dp_bridge_create("br0", &info), LAGOPUS_RESULT_OK);
    TEST_ASSERT_EQUAL(dp_port_create("port1"), LAGOPUS_RESULT_OK);
    TEST_ASSERT_EQUAL(dp_interface_create("interface1"), LAGOPUS_RESULT_OK);
    TEST_ASSERT_EQUAL(dp_port_interface_set("port1", "interface1"),
                      LAGOPUS_RESULT_OK);
    TEST_ASSERT_EQUAL(dp_bridge_port_set("br0", "port1", 1), LAGOPUS_RESULT_OK);

    bridge = dp_bridge_lookup("br0");
    TEST_ASSERT_NOT_NULL(bridge);
    port_mod.port_no = 1;
    port_mod.hw_addr[0] = 0xe0;
    port_mod.hw_addr[1] = 0x4d;
    port_mod.hw_addr[2] = 0xff;
    port_mod.hw_addr[3] = 0x00;
    port_mod.hw_addr[4] = 0x10;
    port_mod.hw_addr[5] = 0x04;
    port_mod.config = 0;
    port_mod.mask = 0;
    rv = port_config(bridge, &port_mod, &error);
    TEST_ASSERT_EQUAL_MESSAGE(rv, LAGOPUS_RESULT_OK,
                              "port_config error");
}
Ejemplo n.º 2
0
void main (void)
{
    Display_Intro();
    init_I2C();
    port_config();
    DISABLE_USB_5V;                     // Disable USB 5v (for Host support)


    MAX3353_ISR();
    
    if(MAX3353_Init())
        printf("\nMAX3353 not Present\n");
    else
        printf("\nMAX3353 Present\n");
      

    while(1)
    {

        /*** Check for changes ****/
        if(FLAG_CHK(_MAX3353,gu8ISR_Flags))
        {
            FLAG_CLR(_MAX3353,gu8ISR_Flags);
            if(gu8MAX3353StatusRegister & ID_GND_EVENT)
            {

                printf("\nID-GND   --> Changing to HOST mode (Enabling 5V)");
                gu8USB_Mode=USB_HOST_MODE_INIT;
            }    
            if(gu8MAX3353StatusRegister & ID_FLOAT_EVENT)
            {
                printf("\nID-FLOAT --> Changing to DEVICE mode (Disabling 5V)");
                gu8USB_Mode=USB_DEVICE_MODE_INIT;
            }    
            if(gu8MAX3353StatusRegister & VBUS_HIGH_EVENT)
            {    
                printf("\nVBUS is Up");
            }

            if(gu8MAX3353StatusRegister & VBUS_LOW_EVENT)
            {    
                printf("\nVBUS is Down");
                if(gu8USB_Mode==USB_DEVICE_MODE)
                    gu8USB_Mode=USB_DEVICE_MODE_INIT;    
                //enter_vlps();   // Enter VLPS
                
                //mcg_pbe_2_pee(); // Exit VLPS
                // Low power
            }
        
        }      

        /* USB Switch stacks */
        USB_State_Machine();

      

    } 
}
Ejemplo n.º 3
0
NetOrientation::NetOrientation(Object* object)
	: my_object(object), my_orientation(nullptr)
{
	std::ifstream port_config("portConfig.txt");
	int port;
	port_config >> port;
	Socket.Bind(port);

	// TODO: This has to be joined or terminated in the destructor perhaps
	task = new std::thread(&NetOrientation::listen, this);
}
Ejemplo n.º 4
0
// Markus Erlach
void open_port(std::string adr) {
    USB_PORT = adr.c_str();
    /*
    O_RDWR = Posix read write
    O_NOCTTY = Not a controlling terminal 
    O_NDELAY = Ignore dcd signal state
    */
    port = open(USB_PORT, O_RDWR | O_NOCTTY);
    if (port != 0) {
        port_config();
    } 
    
}
Ejemplo n.º 5
0
/*
 * port_mod (Agent/DP API)
 */
lagopus_result_t
ofp_port_mod_modify(uint64_t dpid,
                    struct ofp_port_mod *port_mod,
                    struct ofp_error *error) {
  struct bridge *bridge;

  bridge = dp_bridge_lookup_by_dpid(dpid);
  if (bridge == NULL) {
    return LAGOPUS_RESULT_NOT_FOUND;
  }

  return port_config(bridge, port_mod, error);
}
Ejemplo n.º 6
0
void main (void)
{
    Display_Intro();
    init_I2C();
    port_config();
    DISABLE_USB_5V;                     // Disable USB 5v (for Host support)

    if(MAX3353_Init())
        printf("\nMAX3353 not Present\n");
    else
        printf("\nMAX3353 Present\n");
    MAX3353_ISR();

    while(1)
    {
        in_char();   

#if 0 //CW        
        enter_vlps();
#endif //kevin

        //enter_stop();  
        mcg_pbe_2_pee();
        
        if(FLAG_CHK(_MAX3353,gu8ISR_Flags))
        {
            if(gu8MAX3353StatusRegister & ID_GND_EVENT)
            {
                ENABLE_USB_5V;
                printf("\nID-GND   --> Changing to HOST mode (Enabling 5V)");
            }    
            if(gu8MAX3353StatusRegister & ID_FLOAT_EVENT)
            {
                DISABLE_USB_5V;
                printf("\nID-FLOAT --> Changing to DEVICE mode (Disabling 5V)");
            }    
            if(gu8MAX3353StatusRegister & VBUS_HIGH_EVENT)
                printf("\nVBUS is Up");

            if(gu8MAX3353StatusRegister & VBUS_LOW_EVENT)
                printf("\nVBUS is Down");
        
            FLAG_CLR(_MAX3353,gu8ISR_Flags);
        }
    } 
}
Ejemplo n.º 7
0
void TConfigParser::LoadPort(const Json::Value& port_data,
                             const std::string& id_prefix)
{
    if (!port_data.isObject())
        throw TConfigParserException("malformed config");

    if (!port_data.isMember("path"))
        throw TConfigParserException("path not specified");

    if (port_data.isMember("enabled") && !port_data["enabled"].asBool())
        return;

    PPortConfig port_config(new TPortConfig);
    port_config->ConnSettings.Device = port_data["path"].asString();

    if (port_data.isMember("baud_rate"))
        port_config->ConnSettings.BaudRate = GetInt(port_data, "baud_rate");

    if (port_data.isMember("parity"))
        port_config->ConnSettings.Parity = port_data["parity"].asCString()[0]; // FIXME (can be '\0')

    if (port_data.isMember("data_bits"))
        port_config->ConnSettings.DataBits = GetInt(port_data, "data_bits");

    if (port_data.isMember("stop_bits"))
        port_config->ConnSettings.StopBits = GetInt(port_data, "stop_bits");

    if (port_data.isMember("response_timeout_ms"))
        port_config->ConnSettings.ResponseTimeout = std::chrono::milliseconds(
            GetInt(port_data, "response_timeout_ms"));

    if (port_data.isMember("poll_interval"))
        port_config->PollInterval = std::chrono::milliseconds(
            GetInt(port_data, "poll_interval"));

    const Json::Value array = port_data["devices"];
    for(unsigned int index = 0; index < array.size(); ++index)
        LoadDevice(port_config, array[index], id_prefix + std::to_string(index));

    HandlerConfig->AddPortConfig(port_config);
}