реклама на сайте
подробности

 
 
> проблема с serial usb в ecos
asket
сообщение May 16 2012, 10:02
Сообщение #1


Частый гость
**

Группа: Участник
Сообщений: 91
Регистрация: 24-08-06
Из: Москва
Пользователь №: 19 809



Прошу помочь разобраться с проблемой, пишу приложение для at91sam9263 под rtos eCos с использованием встроенных функции eCOS serial USB. Нашел драйвер под win xp/7 ecosusbserial.inf как было описано в доке по eCos, и установил, однако win 7 обнаружила данное устройство, но отказывается его обслуживать, в диспетчере устройств напротив порта восклицательный знак и выдает сообщение, что не в состоянии его запустить, код 10. Если через тот же шнур подключить SAM-BA в режиме RomBoot, то работает нормально, без нареканий. Привожу исходник тестового приложения на ecos:

Код
#define BUF_SIZE        4096

static cyg_uint8     rx_buf[2][BUF_SIZE+1], tx_buf[BUF_SIZE+1];

// --------------------------------------------------------------------------
// Thread receives packets from the USB and sends them out the serial port
// It uses a buffered stdio input, an un-buffered low-level file output.
// This isn't terribly efficient, but rather an example of both methods.

void usb2ser_func(cyg_addrword_t data)
{
    int             n;
    unsigned        ibuf, next_buf;

    DBG("Usb2Ser: Thread starting\n");

  // Give the USB receiver an adequate buffer.
  // setvbuf(rxf, usb2ser_buf, _IOFBF, BUF_SIZE);

    ibuf = 0;

  while (1) {

    // ----- Wait for the host to configure -----

    DBG("Usb2Ser: Waiting for USB configuration\n");

    usbs_serial_wait_until_configured();
    cyg_thread_delay((cyg_tick_count_t) 10);

    // ----- While configured read data & send out serial port -----

    DBG("Usb2Ser: USB configured\n");

    usbs_serial_start_rx(&usbs_ser0, rx_buf[ibuf], BUF_SIZE);

    while (usbs_serial_is_configured()) {

         n = usbs_serial_wait_for_rx(&usbs_ser0);
         next_buf = ibuf ^ 1;

         usbs_serial_start_rx(&usbs_ser0, rx_buf[next_buf], BUF_SIZE);

         if (n < 0) {
                 DBG("*** I/O Error: %d ***\n", n);
         }
         else {
             rx_buf[ibuf][n] = '\0';
             DBG("%s", rx_buf[ibuf]);
         }

         ibuf = next_buf;

    }
  }
}

// --------------------------------------------------------------------------
// Thread receives packets from the serial port and sends them out the USB
// It uses a buffered stdio input, an un-buffered low-level file output.
// This isn't terribly efficient, but rather an example of both methods.

void ser2usb_func(cyg_addrword_t data)
{
    int             n;

    DBG("Ser2Usb: Thread starting\n");

  while (1) {

    // ----- Wait for the host to configure -----

    DBG("Ser2Usb: Waiting for USB configuration\n");
    usbs_serial_wait_until_configured();
    cyg_thread_delay((cyg_tick_count_t) 10);

    // ----- While configured read data & send out serial port -----

    DBG("Ser2Usb: USB configured\n");
    while (usbs_serial_is_configured()) {

        n = 5;

        memset(tx_buf, 0xAA, n);

        usbs_serial_tx(&usbs_ser0, tx_buf, n);
        cyg_thread_delay((cyg_tick_count_t) 1000);

    }
  }
}

// --------------------------------------------------------------------------
//  Application Startup
// --------------------------------------------------------------------------


int main(void)
{

  DBG("Entering usb_serial_send function\n");


  cyg_thread_create(4, usb2ser_func, (cyg_addrword_t) 0,
                    "Usb2Serial", (void *) stack[0], THREAD_STACK_SIZE,
                    &usb2ser_thread, &thread[0]);

  cyg_thread_create(4, ser2usb_func, (cyg_addrword_t) 1,
                    "Serial2Usb", (void *) stack[1], THREAD_STACK_SIZE,
                    &ser2usb_thread, &thread[1]);

  // Start USB subsystem
  usbs_serial_start();

  // Start the threads running.
  cyg_thread_resume(usb2ser_thread);
  cyg_thread_resume(ser2usb_thread);

#if 1
        char ch = 0;
        while (ch != 'q') {
            printf("\r\nPress `q' to quit");
            scanf("%c", &ch);
        }

    #else
        for (;;) {
        }
    #endif



  CYGACC_CALL_IF_RESET();

  //CYGACC_CALL_IF_MONITOR_RETURN(0); // return to RedBoot

  return 0;

}


Это измененный пример тестового исходника из пакета eCos.
Вот что выдает приложение при подключении к ПК.
Код
Entering usb_serial_send function
### 4:Reset ###
Usb2Ser: Thread star### 132:<null> ###
ting
Usb2Ser: Waiting for USB configuration
Ser2Usb: Thread starting
Ser2Usb: Waiting for USB configuration

Press `q' to quit### 4:Reset ###
### 3:Powered ###
### 4:Reset ###
### 3:Powered ###
### 4:Reset ###
### 5:Addressed ###
### 6:Configured ###
### 6:Configured ###
Usb2Ser: USB configured
Ser2Usb: USB configured


Прошу помочь, на что нужно обратить внимание.
Спасибо
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 26th July 2025 - 07:59
Рейтинг@Mail.ru


Страница сгенерированна за 0.01351 секунд с 7
ELECTRONIX ©2004-2016