Win32 IXXAT driver:
authorChristian Taedcke <hacking@taedcke.com>
Wed, 09 Nov 2011 15:02:47 +0000
changeset 689 d6fcd388f2db
parent 688 514108c6e4c4
child 690 1c2cb6088050
Win32 IXXAT driver:
CHANGED: - Removed deprecated call to VCI_GetBrdTypeByName().
- The board type given to VCI2_PrepareBoard() is now always 0, because this parameter is not used.
- Removed the board_name parameter from IXXAT::open(). The board that should be opened is identified by the parameter board_number.
The correct parameter board_number can be determined using XAT_EnumHwEntry() and XAT_GetConfig().
- Changed the constructor IXXAT::IXXAT(). board->busname now only contains the board_number, see XAT_EnumHwEntry() and XAT_GetConfig().
drivers/can_ixxat_win32/ixxat.cpp
--- a/drivers/can_ixxat_win32/ixxat.cpp	Tue Nov 08 09:52:40 2011 +0000
+++ b/drivers/can_ixxat_win32/ixxat.cpp	Wed Nov 09 15:02:47 2011 +0000
@@ -70,8 +70,8 @@
       bool send(const Message *m);
       bool receive(Message *m);
    private:
-      bool open(const char* board_name, int board_number, const char* baud_rate);
-      bool close();                             
+      bool open(int board_number, const char* baud_rate);
+      bool close();
       void receive_queuedata(UINT16 que_hdl, UINT16 count, VCI_CAN_OBJ* p_obj);
       // VCI2 handler      
       static void VCI_CALLBACKATTR message_handler(char *msg_str);
@@ -108,19 +108,20 @@
                                m_RxQueHdl(0xFFFF)
                                
    {
-   char busname[100];
-   ::strcpy(busname,board->busname);
-   char board_name[100];      
-   long board_number = 0;   
-   char *ptr = ::strrchr(busname,':');
-   if (ptr != 0)
-      {
-      *ptr = 0;
-      ::strcpy(board_name,busname);
-      if (++ptr - busname < (int)::strlen(board->busname))
-         board_number = ::atoi(ptr);
-      }
-   if (!open(board_name,board_number,board->baudrate))
+   if (!board)
+      {
+      close();
+      throw error();
+      }
+
+   long board_number = 0;
+
+   if (board->busname)
+      {
+      board_number = atol(board->busname);
+      }
+
+   if (!open(board_number, board->baudrate))
       {
       close();
       throw error();
@@ -165,7 +166,7 @@
    return false;
    }
 
-bool IXXAT::open(const char* board_name, int board_number, const char* baud_rate)
+bool IXXAT::open(int board_number, const char* baud_rate)
    {
    // check, if baudrate is supported
    struct IXXAT_baud_rate_param 
@@ -204,9 +205,8 @@
    // close existing board   
    close();
    // init IXXAT board
-   unsigned long board_type = VCI_GetBrdTypeByName(const_cast<char*>(board_name));
-   long res = VCI2_PrepareBoard( board_type,                  // board type
-                                   board_number,              // unique board index
+   long res = VCI2_PrepareBoard(   0,                         // board type, unused in VCI2
+                                   board_number,              // unique board index, see XAT_EnumHwEntry() and XAT_GetConfig()
                                    NULL,                      // pointer to buffer for additional info 
                                    0,                         // length of additional info buffer
                                    message_handler,           // pointer to msg-callbackhandler
@@ -236,7 +236,7 @@
    res = VCI_ConfigQueue(m_BoardHdl, CAN_NUM, VCI_RX_QUE, 500, 1, 0, 100,  &m_RxQueHdl);
 
    //  assign the all IDs to the Receive Queue
-   res = VCI_AssignRxQueObj(m_BoardHdl, m_RxQueHdl ,VCI_ACCEPT, 0, 0) ;
+   res = VCI_AssignRxQueObj(m_BoardHdl, m_RxQueHdl ,VCI_ACCEPT, 0, 0);
 
    //  And now start the CAN
    res = VCI_StartCan(m_BoardHdl, CAN_NUM);