首页 > 代码库 > 驱动代码

驱动代码

   1 /*******************************************************************************   2 ********************************************************************************   3 **   4 ** File Name   5 ** ---------   6 **   7 ** aplink.c   8 **   9 ********************************************************************************1270 1271 /*------------------------------------------------------------------------------1272 ** aplink_RunCfgStateMachine()1273 **------------------------------------------------------------------------------1274 */1275 1276 void aplink_RunCfgStateMachine( void )1277 {1278    UTIL_BufMsgType*  psQEntry;1279    static UINT16     iMapCntr;1280    static UINT16     iSingleEntrySize;1281    UINT16*           piTemp;1282 1283 1284    switch( aplink_s.eCfgState )1285    {1286    case APLINK_CFG_SM_INIT:1287       /*1288       ** Initialise variables etc.1289       */1290 1291       aplink_s.psReadCfg   = NULL;1292       aplink_s.psWriteCfg  = NULL;1293 1294       aplink_s.iReadPdLength  = 0;1295       aplink_s.iWritePdLength = 0;1296 1297       aplink_s.eCfgState = APLINK_CFG_SM_READ_MODULE_TYPE;1298 1299       ABCC_CbfDebugInfo( "APLINK/Configuration: In APLINK_CFG_SM_INIT." );1300       ABCC_CbfDebugInfo( "APLINK/Configuration: In APLINK_CFG_SM_READ_MODULE_TYPE." );1301 1302 1303       break; /* End case APLINK_CFG_SM_INIT: */1304 1305 1306    case APLINK_CFG_SM_READ_MODULE_TYPE:1307       /*1308       ** Allocate a buffer.1309       */1310 1311       psQEntry = UTIL_AllocateMsgBuffer( &APLINK_asCmdToAbccBuf[ 0 ],1312                                          ABCC_NBR_SIMULTANEOUS_APPL_COMMANDS );1313 1314       if( psQEntry == NULL )1315       {1316          ABCC_CbfDriverError( ABCC_SEV_FATAL, ABCC_EC_OUT_OF_BUFFERS );1317       }1318 1319 1320       /*1321       ** Read the module type of the ABCC module.1322       */1323 1324       psQEntry->sMsg.sHeader.bSourceId = (UINT8)0x01;1325       psQEntry->sMsg.sHeader.bDestObj  = (UINT8)ABP_OBJ_NUM_ANB;1326       psQEntry->sMsg.sHeader.iInstance = 0x0001;1327       psQEntry->sMsg.sHeader.bCmd      = (UINT8)( ABP_CMD_GET_ATTR | ABP_MSG_HEADER_C_BIT );1328       psQEntry->sMsg.sHeader.bDataSize = (UINT8)0x00;1329       psQEntry->sMsg.sHeader.bCmdExt0  = (UINT8)ABP_ANB_IA_MODULE_TYPE;1330       psQEntry->sMsg.sHeader.bCmdExt1  = (UINT8)0x00;1331 1332       /*1333       ** Post the message to the ABCC.1334       */1335 1336       (void)aplink_AddFragAndPostMsg( psQEntry );1337 1338 1339       /*1340       ** Wait for the response.1341       */1342 1343       aplink_s.eCfgState = APLINK_CFG_SM_WAIT_MODULE_TYPE_RSP;1344 1345       ABCC_CbfDebugInfo( "APLINK/Configuration: In APLINK_CFG_SM_WAIT_MODULE_TYPE_RSP." );1346 1347       break; /* End case APLINK_CFG_SM_READ_MODULE_TYPE */1348 1349 1350    case APLINK_CFG_SM_WAIT_MODULE_TYPE_RSP:1351       /*1352       ** Check if theres a new response for us.1353       */1354 1355       if( UTIL_GetFirstMessageFromQueue( aplink_s.xMsgsFromAbccQueue, &psQEntry ) == UTIL_OK )1356       {1357          /*1358          ** Decrease the number of messages that are processing...1359          */1360 1361          aplink_s.bNbrOfCmdsActiveToAbcc--;1362 1363 1364          /*1365          ** We have received a new message.1366          */1367 1368          if( ( psQEntry->sMsg.sHeader.bSourceId == (UINT8)0x01 ) &&1369              ( psQEntry->sMsg.sHeader.bDestObj == (UINT8)ABP_OBJ_NUM_ANB ) &&1370              ( psQEntry->sMsg.sHeader.iInstance == 0x0001 ) &&1371              ( !( (BOOL8)( psQEntry->sMsg.sHeader.bCmd & (UINT8)ABP_MSG_HEADER_C_BIT ) ) ) &&1372              ( !( (BOOL8)( psQEntry->sMsg.sHeader.bCmd & (UINT8)ABP_MSG_HEADER_E_BIT ) ) ) &&1373              ( psQEntry->sMsg.sHeader.bDataSize == (UINT8)ABP_ANB_IA_MODULE_TYPE_DS ) &&1374              ( psQEntry->sMsg.sHeader.bCmdExt0 == (UINT8)ABP_ANB_IA_MODULE_TYPE ) &&1375              ( psQEntry->sMsg.sHeader.bCmdExt1 == (UINT8)0x00 ) )1376          {1377             /*1378             ** Response is OK. Read the data attached.1379             */1380 1381             piTemp = (UINT16*)&psQEntry->sMsg.abData[ 0 ];1382             aplink_s.iModuleType = UTIL_WordToNative( *piTemp );1383 1384             ABCC_CbfDebugInfo( "APLINK/Configuration: Module type response received." );1385 1386             /*1387             ** Read the network data-type.1388             */1389 1390             aplink_s.eCfgState = APLINK_CFG_SM_READ_NW_TYPE;1391 1392             ABCC_CbfDebugInfo( "APLINK/Configuration: In APLINK_CFG_SM_READ_NW_TYPE." );1393          }1394          else1395          {1396             /*1397             ** There is some error in the response.1398             */1399 1400             ABCC_CbfDebugInfo( "APLINK/Configuration: Module type error response." );1401 1402             /*1403             ** Signal a fatal error to the application1404             */1405 1406             ABCC_CbfDriverError( ABCC_SEV_FATAL, ABCC_EC_INVALID_MODULE_TYPE_RECEIVED );1407 1408             /*1409             ** Change driver state, so the applicaton is able to send a RESET1410             */1411 1412             APLINK_ChangeDriverState( APLINK_SM_IN_RUN_NO_PD );1413 1414          } /* End ( Response is not OK? ) */1415 1416          /*1417          ** Free the allocated buffer.1418          */1419 1420          UTIL_FreeMsgBuffer( psQEntry );1421 1422       } /* End if( New message? ) */1423 1424       break; /* End case APLINK_CFG_SM_WAIT_MODULE_TYPE_RSP: */1425 1426 1427    case APLINK_CFG_SM_READ_NW_TYPE:1428       /*1429       ** Allocate a buffer.1430       */1431 1432       psQEntry = UTIL_AllocateMsgBuffer( &APLINK_asCmdToAbccBuf[ 0 ],1433                                          ABCC_NBR_SIMULTANEOUS_APPL_COMMANDS );1434 1435       if( psQEntry == NULL )1436       {1437          ABCC_CbfDriverError( ABCC_SEV_FATAL, ABCC_EC_OUT_OF_BUFFERS );1438       }1439 1440 1441       /*1442       ** Read the network type of the ABCC module.1443       */1444 1445       psQEntry->sMsg.sHeader.bSourceId  = (UINT8)0x01;1446       psQEntry->sMsg.sHeader.bDestObj   = (UINT8)ABP_OBJ_NUM_NW;1447       psQEntry->sMsg.sHeader.iInstance  = 0x0001;1448       psQEntry->sMsg.sHeader.bCmd       = (UINT8)( ABP_CMD_GET_ATTR | ABP_MSG_HEADER_C_BIT );1449       psQEntry->sMsg.sHeader.bDataSize  = (UINT8)0x00;1450       psQEntry->sMsg.sHeader.bCmdExt0   = (UINT8)ABP_NW_IA_NW_TYPE;1451       psQEntry->sMsg.sHeader.bCmdExt1   = (UINT8)0x00;1452 1453 1454       /*1455       ** Post the message to the ABCC module.1456       */1457 1458       (void)aplink_AddFragAndPostMsg( psQEntry );1459 1460 1461       /*1462       ** Fetch the response.1463       */1464 1465       aplink_s.eCfgState = APLINK_CFG_SM_READ_NW_TYPE_RSP;1466 1467       ABCC_CbfDebugInfo( "APLINK/Configuration: In APLINK_CFG_SM_READ_NW_TYPE_RSP." );1468 1469       break; /* End case APLINK_CFG_SM_READ_NW_TYPE: */1470 1471 1472    case APLINK_CFG_SM_READ_NW_TYPE_RSP:1473       /*1474       ** Check if theres a new response for us.1475       */1476 1477       if( UTIL_GetFirstMessageFromQueue( aplink_s.xMsgsFromAbccQueue, &psQEntry ) == UTIL_OK )1478       {1479          /*1480          ** Decrease the number of messages that are processing...1481          */1482 1483          aplink_s.bNbrOfCmdsActiveToAbcc--;1484 1485 1486          /*1487          ** We have received a new message.1488          */1489 1490          if( ( psQEntry->sMsg.sHeader.bSourceId == (UINT8)0x01 ) &&1491              ( psQEntry->sMsg.sHeader.bDestObj == (UINT8)ABP_OBJ_NUM_NW ) &&1492              ( psQEntry->sMsg.sHeader.iInstance == 0x0001 ) &&1493              ( !( (BOOL8)( psQEntry->sMsg.sHeader.bCmd & (UINT8)ABP_MSG_HEADER_C_BIT ) ) ) &&1494              ( !( (BOOL8)( psQEntry->sMsg.sHeader.bCmd & (UINT8)ABP_MSG_HEADER_E_BIT ) ) ) &&1495              ( psQEntry->sMsg.sHeader.bDataSize == (UINT8)ABP_NW_IA_NW_TYPE_DS ) &&1496              ( psQEntry->sMsg.sHeader.bCmdExt0 == (UINT8)ABP_NW_IA_NW_TYPE ) &&1497              ( psQEntry->sMsg.sHeader.bCmdExt1 == (UINT8)0x00 ) )1498          {1499             /*1500             ** Response is OK. Read the data attached.1501             */1502 1503             piTemp = (UINT16*)&psQEntry->sMsg.abData[ 0 ];1504             aplink_s.iNetworkType = UTIL_WordToNative( *piTemp );1505 //                         AT24CXX_WriteOneByte(10,aplink_s.iNetworkType);/* 引起死机 */1506                      fsmc_sram_test_write(aplink_s.iNetworkType,2);1507                      1508             ABCC_CbfDebugInfo( "APLINK/Configuration: Network type response received." );1509                      1510                      1511 1512             /*1513             ** Read the network parameter support.1514             */1515 1516             aplink_s.eCfgState = APLINK_CFG_SM_READ_NW_PARAM_SUPPORT;1517 1518             ABCC_CbfDebugInfo( "APLINK/Configuration: In APLINK_CFG_SM_READ_NW_PARAM_SUPPORT." );1519 1520          }1521          else1522          {1523             /*1524             ** There is some error in the response.1525             */1526 1527             ABCC_CbfDebugInfo( "APLINK/Configuration: Network Type error response." );1528 1529             /*1530             ** Signal a fatal error to the application1531             */1532 1533             ABCC_CbfDriverError( ABCC_SEV_FATAL, ABCC_EC_INVALID_NETWORK_TYPE_RECEIVED );1534 1535             /*1536             ** Change driver state, so the applicaton is able to send a RESET1537             */1538 1539             APLINK_ChangeDriverState( APLINK_SM_IN_RUN_NO_PD );1540 1541          } /* End if( Response OK? ) */1542 1543          /*1544          ** Free the allocated buffer.1545          */1546 1547          UTIL_FreeMsgBuffer( psQEntry );1548 1549       } /* End if( New message? ) */1550             1551 1552       break; /* End case APLINK_CFG_SM_READ_NW_TYPE_RSP: */1553 1554 1555    case APLINK_CFG_SM_READ_NW_PARAM_SUPPORT:1556       /*1557       ** Allocate a buffer.1558       */1559 1560       psQEntry = UTIL_AllocateMsgBuffer( &APLINK_asCmdToAbccBuf[ 0 ],1561                                          ABCC_NBR_SIMULTANEOUS_APPL_COMMANDS );1562 1563       if( psQEntry == NULL )1564       {1565          ABCC_CbfDriverError( ABCC_SEV_FATAL, ABCC_EC_OUT_OF_BUFFERS );1566       }1567 1568 1569       /*1570       ** Read the network parameter support of the ABCC module.1571       */1572 1573       psQEntry->sMsg.sHeader.bSourceId  = (UINT8)0x01;1574       psQEntry->sMsg.sHeader.bDestObj   = (UINT8)ABP_OBJ_NUM_NW;1575       psQEntry->sMsg.sHeader.iInstance  = 0x0001;1576       psQEntry->sMsg.sHeader.bCmd       = (UINT8)( ABP_CMD_GET_ATTR | ABP_MSG_HEADER_C_BIT );1577       psQEntry->sMsg.sHeader.bDataSize  = (UINT8)0x00;1578       psQEntry->sMsg.sHeader.bCmdExt0   = (UINT8)ABP_NW_IA_PARAM_SUPPORT;1579       psQEntry->sMsg.sHeader.bCmdExt1   = (UINT8)0x00;1580 1581 1582       /*1583       ** Post the message to the ABCC module.1584       */1585 1586       (void)aplink_AddFragAndPostMsg( psQEntry );1587 1588 1589       /*1590       ** Fetch the response.1591       */1592 1593       aplink_s.eCfgState = APLINK_CFG_SM_READ_NW_PARAM_SUPPORT_RSP;1594 1595       ABCC_CbfDebugInfo( "APLINK/Configuration: In APLINK_CFG_SM_READ_NW_PARAM_SUPPORT_RSP." );1596 1597       break; /* End case APLINK_CFG_SM_READ_NW_PARAM_SUPPORT: */1598 1599 1600    case APLINK_CFG_SM_READ_NW_PARAM_SUPPORT_RSP:1601       /*1602       ** Check if theres a new response for us.1603       */1604 1605       if( UTIL_GetFirstMessageFromQueue( aplink_s.xMsgsFromAbccQueue, &psQEntry ) == UTIL_OK )1606       {1607          /*1608          ** Decrease the number of messages that are processing...1609          */1610 1611          aplink_s.bNbrOfCmdsActiveToAbcc--;1612 1613 1614          /*1615          ** We have received a new message.1616          */1617 1618          if( ( psQEntry->sMsg.sHeader.bSourceId == (UINT8)0x01 ) &&1619              ( psQEntry->sMsg.sHeader.bDestObj == (UINT8)ABP_OBJ_NUM_NW ) &&1620              ( psQEntry->sMsg.sHeader.iInstance == 0x0001 ) &&1621              ( !( (BOOL8)( psQEntry->sMsg.sHeader.bCmd & (UINT8)ABP_MSG_HEADER_C_BIT ) ) ) &&1622              ( !( (BOOL8)( psQEntry->sMsg.sHeader.bCmd & (UINT8)ABP_MSG_HEADER_E_BIT ) ) ) &&1623              ( psQEntry->sMsg.sHeader.bDataSize == (UINT8)ABP_NW_IA_PARAM_SUPPORT_DS ) &&1624              ( psQEntry->sMsg.sHeader.bCmdExt0 == (UINT8)ABP_NW_IA_PARAM_SUPPORT ) &&1625              ( psQEntry->sMsg.sHeader.bCmdExt1 == (UINT8)0x00 ) )1626          {1627             /*1628             ** Response is OK. Read the data attached.1629             */1630 1631             aplink_s.bParamSupport = psQEntry->sMsg.abData[ 0 ];1632 1633             ABCC_CbfDebugInfo( "APLINK/Configuration: Parameter support response received." );1634 1635 1636             /*1637             ** Request pointers for the configuration.1638             */1639 1640             ABCC_CbfAutoCfgRequest( aplink_s.iModuleType,1641                                     aplink_s.iNetworkType,1642                                     aplink_s.bParamSupport,1643                                     &aplink_s.psReadCfg,1644                                     &aplink_s.psWriteCfg );1645 1646 1647             /*1648             ** Read the network data format support.1649             */1650 1651             aplink_s.eCfgState = APLINK_CFG_SM_READ_NW_DATA_FORMAT;1652 1653             ABCC_CbfDebugInfo( "APLINK/Configuration: In APLINK_CFG_SM_READ_NW_DATA_FORMAT." );1654          }1655          else1656          {1657             /*1658             ** There is some error in the response.1659             */1660 1661             ABCC_CbfDebugInfo( "APLINK/Configuration: Parameter support error response." );1662 1663             /*1664             ** Signal a fatal error to the application1665             */1666 1667             ABCC_CbfDriverError( ABCC_SEV_FATAL, ABCC_EC_INVALID_PARAM_SUPPORT_RECEIVED );1668 1669             /*1670             ** Change driver state, so the applicaton is able to send a RESET1671             */1672 1673             APLINK_ChangeDriverState( APLINK_SM_IN_RUN_NO_PD );1674 1675          } /* End if( Response OK? ) */1676 1677          /*1678          ** Free the allocated buffer.1679          */1680 1681          UTIL_FreeMsgBuffer( psQEntry );1682 1683       } /* End if( New message? ) */1684             1685 1686 1687       break; /* End case APLINK_CFG_SM_READ_NW_PARAM_SUPPORT_RSP: */1688 1689 1690    case APLINK_CFG_SM_READ_NW_DATA_FORMAT:1691       /*1692       ** Allocate a buffer.1693       */1694 1695       psQEntry = UTIL_AllocateMsgBuffer( &APLINK_asCmdToAbccBuf[ 0 ],1696                                          ABCC_NBR_SIMULTANEOUS_APPL_COMMANDS );1697 1698       if( psQEntry == NULL )1699       {1700          ABCC_CbfDriverError( ABCC_SEV_FATAL, ABCC_EC_OUT_OF_BUFFERS );1701       }1702 1703 1704       /*1705       ** Read the Network data format of the module.1706       */1707 1708       psQEntry->sMsg.sHeader.bSourceId  = (UINT8)0x01;1709       psQEntry->sMsg.sHeader.bDestObj   = (UINT8)ABP_OBJ_NUM_NW;1710       psQEntry->sMsg.sHeader.iInstance  = 0x0001;1711       psQEntry->sMsg.sHeader.bCmd       = (UINT8)( ABP_CMD_GET_ATTR | ABP_MSG_HEADER_C_BIT );1712       psQEntry->sMsg.sHeader.bDataSize  = (UINT8)0x00;1713       psQEntry->sMsg.sHeader.bCmdExt0   = (UINT8)ABP_NW_IA_DATA_FORMAT;1714       psQEntry->sMsg.sHeader.bCmdExt1   = (UINT8)0x00;1715 1716       /*1717       ** Post the message to the ABCC.1718       */1719 1720       (void)aplink_AddFragAndPostMsg( psQEntry );1721 1722 1723       /*1724       ** Wait for the response.1725       */1726 1727       aplink_s.eCfgState = APLINK_CFG_SM_WAIT_NW_DATA_FORMAT_RSP;1728 1729       ABCC_CbfDebugInfo( "APLINK/Configuration: In APLINK_CFG_SM_WAIT_NW_DATA_FORMAT_RSP." );1730 1731       break; /* End case APLINK_CFG_SM_READ_NW_DATA_FORMAT: */1732 1733 1734    case APLINK_CFG_SM_WAIT_NW_DATA_FORMAT_RSP:1735       /*1736       ** Check if theres a new response for us.1737       */1738 1739       if( UTIL_GetFirstMessageFromQueue( aplink_s.xMsgsFromAbccQueue, &psQEntry ) == UTIL_OK )1740       {1741          /*1742          ** Decrease the number of messages that are processing...1743          */1744 1745          aplink_s.bNbrOfCmdsActiveToAbcc--;1746 1747 1748          /*1749          ** We have received a new message.1750          */1751 1752          if( ( psQEntry->sMsg.sHeader.bSourceId == (UINT8)0x01 ) &&1753              ( psQEntry->sMsg.sHeader.bDestObj == (UINT8)ABP_OBJ_NUM_NW ) &&1754              ( psQEntry->sMsg.sHeader.iInstance == 0x0001 ) &&1755              ( !( (BOOL8)( psQEntry->sMsg.sHeader.bCmd & (UINT8)ABP_MSG_HEADER_C_BIT ) ) ) &&1756              ( !( (BOOL8)( psQEntry->sMsg.sHeader.bCmd & (UINT8)ABP_MSG_HEADER_E_BIT ) ) ) &&1757              ( psQEntry->sMsg.sHeader.bDataSize == (UINT8)ABP_NW_IA_DATA_FORMAT_DS ) &&1758              ( psQEntry->sMsg.sHeader.bCmdExt0 == (UINT8)ABP_NW_IA_DATA_FORMAT ) &&1759              ( psQEntry->sMsg.sHeader.bCmdExt1 == (UINT8)0x00 ) )1760          {1761             /*1762             ** Signal the network data format to the application.1763             */1764 1765             ABCC_CbfNetworkDataFormat( (ABCC_DataFormatType)psQEntry->sMsg.abData[ 0 ] );1766 1767             ABCC_CbfDebugInfo( "APLINK/Configuration: Network data-type response received." );1768 1769             iMapCntr = 0;1770 1771             /*1772             ** Change state1773             */1774 1775             aplink_s.eCfgState = APLINK_CFG_SM_NEXT_READ;1776 1777          }1778          else1779          {1780             /*1781             ** There is some error in the response.1782             */1783 1784             ABCC_CbfDebugInfo( "APLINK/Configuration: Network data-format error response." );1785 1786             /*1787             ** Signal a fatal error to the application1788             */1789 1790             ABCC_CbfDriverError( ABCC_SEV_FATAL, ABCC_EC_INVALID_DATA_FORMAT_RECEIVED );1791 1792             /*1793             ** Change driver state, so the applicaton is able to send a RESET1794             */1795 1796             APLINK_ChangeDriverState( APLINK_SM_IN_RUN_NO_PD );1797 1798          } /* End if( New Message OK? ) */1799 1800          /*1801          ** Free the allocated buffer.1802          */1803 1804          UTIL_FreeMsgBuffer( psQEntry );1805 1806       } /* End if( New message? ) */1807             1808 1809                 ABCC_CbfCfgSetAddress( Network_Address());1810 1811       break; /* End case APLINK_CFG_SM_WAIT_NW_DATA_FORMAT_RSP: */1812 1813 1814    case APLINK_CFG_SM_SEND_READ_MAPPING:1815       /*1816       ** Allocate a buffer.1817       */1818 1819       psQEntry = UTIL_AllocateMsgBuffer( &APLINK_asCmdToAbccBuf[ 0 ],1820                                          ABCC_NBR_SIMULTANEOUS_APPL_COMMANDS );1821 1822       if( psQEntry == NULL )1823       {1824          ABCC_CbfDriverError( ABCC_SEV_FATAL, ABCC_EC_OUT_OF_BUFFERS );1825       }1826 1827 1828       /*1829       ** Send a Read mapping message1830       */1831 1832       psQEntry->sMsg.sHeader.bSourceId = (UINT8)0x01;1833       psQEntry->sMsg.sHeader.bDestObj  = (UINT8)ABP_OBJ_NUM_NW;1834       psQEntry->sMsg.sHeader.iInstance = 0x0001;1835       psQEntry->sMsg.sHeader.bCmd      = (UINT8)( ABP_NW_CMD_MAP_ADI_READ_AREA | ABP_MSG_HEADER_C_BIT );1836       psQEntry->sMsg.sHeader.bDataSize = (UINT8)0x04;1837       psQEntry->sMsg.sHeader.bCmdExt0  = (UINT8)( aplink_s.psReadCfg->psMaps[ iMapCntr ].iAdiNbr & 0x00FF );1838       psQEntry->sMsg.sHeader.bCmdExt1  = (UINT8)( ( aplink_s.psReadCfg->psMaps[ iMapCntr ].iAdiNbr >> 8 ) & 0x00FF );1839 1840       /*1841       ** Assign the data type and the number of elements.1842       */1843 1844             if(fsmc_sram_test_read(2) == 0X90)1845             {1846         aplink_s.psReadCfg->psMaps[ iMapCntr ].bDataType = 0;1847                 aplink_s.psReadCfg->psMaps[ iMapCntr ].bNbrElements = 16;1848                  psQEntry->sMsg.abData[ 0 ] = aplink_s.psReadCfg->psMaps[ iMapCntr ].bDataType;1849                  psQEntry->sMsg.abData[ 1 ] = aplink_s.psReadCfg->psMaps[ iMapCntr ].bNbrElements;1850             }1851             else1852             {1853              psQEntry->sMsg.abData[ 0 ] = aplink_s.psReadCfg->psMaps[ iMapCntr ].bDataType;1854        psQEntry->sMsg.abData[ 1 ] = aplink_s.psReadCfg->psMaps[ iMapCntr ].bNbrElements;1855             }1856 //             printf("%2X\r\n",psQEntry->sMsg.abData[ 0 ] );1857 //             printf("%2X\r\n",psQEntry->sMsg.abData[ 1 ] );            1858 1859       /*1860       ** Assign the order number. Low byte first.1861       */1862 1863       psQEntry->sMsg.abData[ 2 ]  = (UINT8)( aplink_s.psReadCfg->psMaps[ iMapCntr ].iOrderNumber & 0x00FF );1864       psQEntry->sMsg.abData[ 3 ]  = (UINT8)( ( aplink_s.psReadCfg->psMaps[ iMapCntr ].iOrderNumber >> 8 ) & 0x00FF );1865 1866       /*1867       ** Store the number of bytes of this mapping.1868       */1869 1870       iSingleEntrySize = ( aplink_GetSizeOfDataType( aplink_s.psReadCfg->psMaps[ iMapCntr ].bDataType ) *1871                            aplink_s.psReadCfg->psMaps[ iMapCntr ].bNbrElements );1872 1873 1874       /*1875       ** Post the message to the ABCC.1876       */1877 1878       (void)aplink_AddFragAndPostMsg( psQEntry );1879 1880 1881       /*1882       ** Change state1883       */1884 1885       aplink_s.eCfgState = APLINK_CFG_SM_WAIT_READ_MAPPING_RSP;1886 1887       ABCC_CbfDebugInfo( "APLINK/Configuration: In APLINK_CFG_SM_WAIT_READ_MAPPING_RSP." );1888 1889       break; /* End case APLINK_CFG_SM_SEND_READ_MAPPING: */1890 1891 1892    case APLINK_CFG_SM_WAIT_READ_MAPPING_RSP:1893       /*1894       ** Waite for a response1895       */1896 1897       if( UTIL_GetFirstMessageFromQueue( aplink_s.xMsgsFromAbccQueue, &psQEntry ) == UTIL_OK )1898       {1899          /*1900          ** Decrease the number of messages that are processing...1901          */1902 1903          aplink_s.bNbrOfCmdsActiveToAbcc--;1904 1905 1906          /*1907          ** We have received a new message.1908          */1909 1910          if( ( psQEntry->sMsg.sHeader.bSourceId == (UINT8)0x01 ) &&1911              ( psQEntry->sMsg.sHeader.bDestObj == (UINT8)ABP_OBJ_NUM_NW ) &&1912              ( psQEntry->sMsg.sHeader.iInstance == 0x0001 ) &&1913              ( !( (BOOL8)( psQEntry->sMsg.sHeader.bCmd & (UINT8)ABP_MSG_HEADER_C_BIT ) ) ) &&1914              ( !( (BOOL8)( psQEntry->sMsg.sHeader.bCmd & (UINT8)ABP_MSG_HEADER_E_BIT ) ) ) &&1915              ( psQEntry->sMsg.sHeader.bDataSize == (UINT8)0x01 ) &&1916              ( psQEntry->sMsg.sHeader.bCmdExt0 == (UINT8)( aplink_s.psReadCfg->psMaps[ iMapCntr ].iAdiNbr & 0x00FF ) ) &&1917              ( psQEntry->sMsg.sHeader.bCmdExt1 == (UINT8)( ( aplink_s.psReadCfg->psMaps[ iMapCntr ].iAdiNbr >> 8 ) & 0x00FF ) ) )1918          {1919             ABCC_CbfDebugInfo( "APLINK/Configuration: Read map added OK." );1920 1921             /*1922             ** Response is OK. Read the data attached.1923             */1924 1925             aplink_s.psReadCfg->psMaps[ iMapCntr ].bAreaOffset = psQEntry->sMsg.abData[ 0 ];1926             aplink_s.psReadCfg->psMaps[ iMapCntr ].bMapStatus  = (UINT8)1;1927 1928             /*1929             ** Add the mapped data size.1930             */1931 1932             aplink_s.iReadPdLength += iSingleEntrySize;1933 1934          }1935          else1936          {1937             /*1938             ** Error in message1939             */1940 1941             ABCC_CbfDebugInfo( "APLINK/Configuration: Read map error." );1942 1943             /*1944             ** Response is NOT OK. Mark the mapping as not mapped.1945             */1946 1947             aplink_s.psReadCfg->psMaps[ iMapCntr ].bAreaOffset = (UINT8)0;1948             aplink_s.psReadCfg->psMaps[ iMapCntr ].bMapStatus  = (UINT8)0;1949 1950          } /* End if( correct message? ) */1951 1952 1953          /*1954          ** Increase the number of mappings.1955          */1956 1957          iMapCntr++;1958 1959 1960          /*1961          ** Check for more mappings.1962          */1963 1964          aplink_s.eCfgState = APLINK_CFG_SM_NEXT_READ;1965 1966 1967          /*1968          ** Free the allocated buffer.1969          */1970 1971          UTIL_FreeMsgBuffer( psQEntry );1972 1973       } /* End if( New Response? ) */1974 1975       break; /* End case APLINK_CFG_SM_WAIT_READ_MAPPING_RSP: */1976 1977 1978    case APLINK_CFG_SM_NEXT_READ:1979       /*1980       ** Check if there are more mappings.1981       */1982 1983       if( ( aplink_s.psReadCfg != NULL ) &&1984           ( aplink_s.psReadCfg->iNbrMaps != 0 ) &&1985           ( aplink_s.psReadCfg->iNbrMaps <= 256 ) &&1986           ( iMapCntr < aplink_s.psReadCfg->iNbrMaps ) )1987       {1988          /*1989          ** There are more "READ"-mappings left. Change state.1990          */1991 1992          aplink_s.eCfgState = APLINK_CFG_SM_SEND_READ_MAPPING;1993       }1994       else1995       {1996          /*1997          ** Check if there is a write mapping available1998          */1999 2000          if( ( aplink_s.psWriteCfg != NULL ) &&2001              ( aplink_s.psWriteCfg->iNbrMaps != 0 ) &&2002              ( aplink_s.psWriteCfg->iNbrMaps <= 256 ) )2003          {2004             /*2005             ** There are at least one write mapping available2006             */2007 2008             iMapCntr = 0;2009 2010             /*2011             ** Change state2012             */2013 2014             aplink_s.eCfgState = APLINK_CFG_SM_SEND_WRITE_MAPPING;2015 2016             ABCC_CbfDebugInfo( "APLINK/Configuration: In APLINK_CFG_SM_SEND_WRITE_MAPPING." );2017          }2018          else2019          {2020             /*2021             ** There are NO "WRITE"-mappings. Change driver state.2022             */2023 2024             APLINK_ChangeDriverState( APLINK_SM_IN_RUN_NO_PD );2025 2026 2027             /*2028             ** No read or write mapping available2029             */2030 2031             ABCC_CbfCfgCompleted();2032 2033          } /* End if write mapping OK? ) */2034 2035       } /* End if( More Read mappings? ) */2036 2037       break; /* End case APLINK_CFG_SM_NEXT_READ: */2038 2039 2040    case APLINK_CFG_SM_SEND_WRITE_MAPPING:2041       /*2042       ** Allocate a buffer.2043       */2044 2045       psQEntry = UTIL_AllocateMsgBuffer( &APLINK_asCmdToAbccBuf[ 0 ],2046                                          ABCC_NBR_SIMULTANEOUS_APPL_COMMANDS );2047 2048       if( psQEntry == NULL )2049       {2050          ABCC_CbfDriverError( ABCC_SEV_FATAL, ABCC_EC_OUT_OF_BUFFERS );2051       }2052 2053 2054       /*2055       ** Send a Write mapping meassage2056       */2057 2058       psQEntry->sMsg.sHeader.bSourceId  = (UINT8)0x01;2059       psQEntry->sMsg.sHeader.bDestObj   = (UINT8)ABP_OBJ_NUM_NW;2060       psQEntry->sMsg.sHeader.iInstance  = 0x0001;2061       psQEntry->sMsg.sHeader.bCmd       = (UINT8)( ABP_NW_CMD_MAP_ADI_WRITE_AREA | ABP_MSG_HEADER_C_BIT );2062       psQEntry->sMsg.sHeader.bDataSize  = (UINT8)0x04;2063       psQEntry->sMsg.sHeader.bCmdExt0   = (UINT8)( aplink_s.psWriteCfg->psMaps[ iMapCntr ].iAdiNbr & 0x00FF );2064       psQEntry->sMsg.sHeader.bCmdExt1   = (UINT8)( ( aplink_s.psWriteCfg->psMaps[ iMapCntr ].iAdiNbr >> 8 ) & 0x00FF );2065 2066       /*2067       ** Assign the data type and number of elements.2068       */2069 2070             if(fsmc_sram_test_read(2) == 0X90)2071             {2072                 aplink_s.psWriteCfg->psMaps[ iMapCntr ].bDataType = 0;2073                 aplink_s.psWriteCfg->psMaps[ iMapCntr ].bNbrElements = 16;2074                 psQEntry->sMsg.abData[ 0 ] = aplink_s.psWriteCfg->psMaps[ iMapCntr ].bDataType;2075                 psQEntry->sMsg.abData[ 1 ] = aplink_s.psWriteCfg->psMaps[ iMapCntr ].bNbrElements;2076             }2077      else2078             {2079                 psQEntry->sMsg.abData[ 0 ] = aplink_s.psWriteCfg->psMaps[ iMapCntr ].bDataType;2080                 psQEntry->sMsg.abData[ 1 ] = aplink_s.psWriteCfg->psMaps[ iMapCntr ].bNbrElements; 2081             }2082 2083       /*2084       ** Assign the order number. Low byte first.2085       */2086 2087       psQEntry->sMsg.abData[ 2 ]  = (UINT8)( aplink_s.psWriteCfg->psMaps[ iMapCntr ].iOrderNumber & 0x00FF );2088       psQEntry->sMsg.abData[ 3 ]  = (UINT8)( ( aplink_s.psWriteCfg->psMaps[ iMapCntr ].iOrderNumber >> 8 ) & 0x00FF );2089 2090 2091       /*2092       ** Store the number of bytes of this mapping.2093       */2094 2095       iSingleEntrySize = ( aplink_GetSizeOfDataType( aplink_s.psWriteCfg->psMaps[ iMapCntr ].bDataType ) *2096                            aplink_s.psWriteCfg->psMaps[ iMapCntr ].bNbrElements );2097 2098       /*2099       ** Post the message to the ABCC.2100       */2101 2102       (void)aplink_AddFragAndPostMsg( psQEntry );2103 2104 2105       /*2106       ** Change state2107       */2108 2109       aplink_s.eCfgState = APLINK_CFG_SM_WAIT_WRITE_MAPPING_RSP;2110 2111       ABCC_CbfDebugInfo( "APLINK/Configuration: In APLINK_CFG_SM_WAIT_WRITE_MAPPING_RSP." );2112 2113       break; /* End case APLINK_CFG_SM_SEND_WRITE_MAPPING: */2114 2115 2116    case APLINK_CFG_SM_WAIT_WRITE_MAPPING_RSP:2117       /*2118       ** Waite for a response2119       */2120 2121       if( UTIL_GetFirstMessageFromQueue( aplink_s.xMsgsFromAbccQueue, &psQEntry ) == UTIL_OK )2122       {2123          /*2124          ** Decrease the number of messages that are processing...2125          */2126 2127          aplink_s.bNbrOfCmdsActiveToAbcc--;2128 2129 2130          /*2131          ** We have received a new message.2132          */2133 2134          if( ( psQEntry->sMsg.sHeader.bSourceId == (UINT8)0x01 ) &&2135              ( psQEntry->sMsg.sHeader.bDestObj == (UINT8)ABP_OBJ_NUM_NW ) &&2136              ( psQEntry->sMsg.sHeader.iInstance == 0x0001 ) &&2137              ( !( (BOOL8)( psQEntry->sMsg.sHeader.bCmd & (UINT8)ABP_MSG_HEADER_C_BIT ) ) ) &&2138              ( !( (BOOL8)( psQEntry->sMsg.sHeader.bCmd & (UINT8)ABP_MSG_HEADER_E_BIT ) ) ) &&2139              ( psQEntry->sMsg.sHeader.bDataSize == (UINT8)0x01 ) &&2140              ( psQEntry->sMsg.sHeader.bCmdExt0 == (UINT8)( aplink_s.psWriteCfg->psMaps[ iMapCntr ].iAdiNbr & 0x00FF ) ) &&2141              ( psQEntry->sMsg.sHeader.bCmdExt1 == (UINT8)( ( aplink_s.psWriteCfg->psMaps[ iMapCntr ].iAdiNbr >> 8 ) & 0x00FF ) ) )2142          {2143             /*2144             ** Response is OK. Read the data attached.2145             */2146       2147             aplink_s.psWriteCfg->psMaps[ iMapCntr ].bAreaOffset = psQEntry->sMsg.abData[ 0 ];2148             aplink_s.psWriteCfg->psMaps[ iMapCntr ].bMapStatus  = (UINT8)1;2149 2150             /*2151             ** Add the mapped data size.2152             */2153 2154             aplink_s.iWritePdLength += iSingleEntrySize;2155 2156 2157             ABCC_CbfDebugInfo( "APLINK/Configuration: Write map OK." );2158          }2159          else2160          {2161             /*2162             ** Error in message2163             */2164 2165             ABCC_CbfDebugInfo( "APLINK/Configuration: Write map error." );2166 2167             /*2168             ** Response is NOT OK. Mark the map.2169             */2170 2171             aplink_s.psWriteCfg->psMaps[ iMapCntr ].bAreaOffset = (UINT8)0;2172             aplink_s.psWriteCfg->psMaps[ iMapCntr ].bMapStatus  = (UINT8)0;2173 2174          } /* End if( correct message? ) */2175 2176 2177          /*2178          ** Increase the number of mappings.2179          */2180 2181          iMapCntr++;2182 2183 2184          /*2185          ** Check if more mappings...2186          */2187 2188          aplink_s.eCfgState = APLINK_CFG_SM_NEXT_WRITE;2189 2190                     2191          /*2192          ** Free the allocated buffer.2193          */2194 2195          UTIL_FreeMsgBuffer( psQEntry );2196                  2197 //                      ABCC_CbfCfgSetAddress(Network_Address());2198 //                     ABCC_CbfCfgSetBand(Network_Band());   //这儿加的设置波特率的函数2199 2200       } /* End if( New Response? ) */2201 2202       break; /* End case APLINK_CFG_SM_WAIT_WRITE_MAPPING_RSP: */2203 2204 2205    case APLINK_CFG_SM_NEXT_WRITE:2206       /*2207       ** Check if there are more "WRITE"-mappings to process.2208       */2209 2210       if( iMapCntr < aplink_s.psWriteCfg->iNbrMaps )2211       {2212          /*2213          ** Change state2214          */2215 2216          aplink_s.eCfgState = APLINK_CFG_SM_SEND_WRITE_MAPPING;2217       }2218       else2219       {2220          /*2221          ** No more mappings to process.2222          ** Change driver state2223          */2224         2225          APLINK_ChangeDriverState( APLINK_SM_IN_RUN_NO_PD );2226 2227          /*2228          ** No more mapping available2229          */2230                 2231                 2232 //        if(fsmc_sram_test_read(2) == 0X90)/*只有在模块是CC-Link时,才配置波特率*/2233 //         {2234                              2235 // //      }2236          ABCC_CbfCfgCompleted();2237 2238       } /* End if( More Write mappings? ) */2239 2240       break; /* End case APLINK_CFG_SM_NEXT_WRITE: */2241 2242 2243    default:2244 2245       /*2246       ** Signal a fatal error to the application2247       */2248 2249       ABCC_CbfDriverError( ABCC_SEV_FATAL, ABCC_EC_ILLEGAL_CFG_STATE );2250 2251       break;2252 2253    } /* End switch( aplink_s.eCfgState ) */2254 2255 } /* End of aplink_RunCfgStateMachine() */2256 2257 2258 /*------------------------------------------------------------------------------2259 ** aplink_HandleQueuedMsgsToAppl()2260 **------------------------------------------------------------------------------2261 */2262
 1 void ABCC_CbfCfgSetBand( UINT8 band ) 2 { 3      4     /* Message Definition */ 5    ABP_MsgType sMsg; 6    sMsg.sHeader.bSourceId = 4;// SourceId = 3 7    sMsg.sHeader.bDestObj = 4;// Object Anybus Object (04h) 8    sMsg.sHeader.iInstance = 2;// Instance = 1 9    sMsg.sHeader.bCmd = 0x42;// Command, Set attribute10    sMsg.sHeader.bDataSize = 1;// Data size = 1 byte11    sMsg.sHeader.bCmdExt0 = 5;// Attribute = 5 (‘setup Complete‘-flag)12    sMsg.sHeader.bCmdExt1 = 0;// (reserved)13    sMsg.abData[ 0 ] = band;// Data14    ABCC_SendMessage( &sMsg ); // Send Message15 16 } /* End of  ABCC_CbfCfgSetBand() */  //设置波特率的函数

/***************log******************************************************/

  1 成功打开串口监视, 进程: 14124    ABCC_Demo_v2.0.exe  2   3 //Control register: bit7    bit6     bit5    bit4    bit3   bit2   bit1   bit0  4             CTRL_T  CTRL_M   CTRL_R  CTRL_AUX   0     0      0      0  5       6 //Status  register: bit7    bit6     bit5    bit4    bit3   bit2   bit1   bit0  7            STAT_T  STAT_M   STAT_R  STAT_AUX  SUP    S2     S1     S0      8                             SETUP:   0      0      0  9                            NW_INT:   0      0      1     10                          WAIT_PROCESS:   0      1      0 11                              IDLE:   0      1      1  12                        PROCESS_ACTIVE:   1      0      0 13                             ERROR:   1      0      1 14                          reserved:   1      1      0 15                         EXCEPTION:   1      1      1 16  17 COM1: 打开                                            //COM1 Write为application向ABCC写数据,COM1 Read为ABCC向application写数据 18  19             /**********SETUP状态开始**********/ 20 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08     //Initial Handshake, both app and module is ready 21 COM1 Read(hex): 19(Bytes) A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08  22  23  24  25 COM1 Write(hex): 19(Bytes)60 01 01 01 00 41 00 01 00 02 01 01 00 00 00 00 00 CE 65     //依次为:Control register 60, source ID 01, Object 01, instance number 00 01, 26                                              41h为读命令,00指message无数据,attribute为00 01,查软件手册中对object 01,                                                 instance 01,attribute 01可知该message含义为读模块类型 27 COM1 Read(hex): 19(Bytes) 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69     //no valid message but for ping_pong 28 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08     //to end last command 29 COM1 Read(hex): 19(Bytes) E0 01 01 01 00 01 02 01 00 01 04 00 00 00 00 00 00 65 1A     //response,0401h, indicate Anybus-CompactCom  30 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69  31 COM1 Read(hex): 19(Bytes) 20 01 01 01 00 01 02 01 00 01 04 00 00 00 00 00 00 59 4A     //to end last response 32  33  34  35 COM1 Write(hex): 19(Bytes)E0 01 03 01 00 41 00 01 00 02 01 01 00 00 00 00 00 27 86     //03(object), 00 01(instance),00 01(attribute). get network object, network                                                     type     attribute  36 COM1 Read(hex): 19(Bytes) A0 01 01 01 00 01 02 01 00 01 04 00 00 00 00 00 00 B1 2B  37 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69  38 COM1 Read(hex): 19(Bytes) 20 01 01 01 00 01 02 01 00 01 04 00 00 00 00 00 00 59 4A  39 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08  40 COM1 Read(hex): 19(Bytes) E0 01 03 01 00 01 02 01 00 25 00 00 00 00 00 00 00 4F DE     //0020h, indicate "DeviceNet" type 41 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69  42 COM1 Read(hex): 19(Bytes) 20 01 03 01 00 01 02 01 00 25 00 00 00 00 00 00 00 73 8E  43  44  45  46 COM1 Write(hex): 19(Bytes)E0 01 03 01 00 41 00 04 00 02 01 01 00 00 00 00 00 37 96     //03,01,04,get network object, Parameter Data support?  47 COM1 Read(hex): 19(Bytes) A0 01 03 01 00 01 02 01 00 25 00 00 00 00 00 00 00 9B EF  48 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69  49 COM1 Read(hex): 19(Bytes) 20 01 03 01 00 01 02 01 00 25 00 00 00 00 00 00 00 73 8E  50 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08  51 COM1 Read(hex): 19(Bytes) E0 01 03 01 00 01 01 04 00 01 00 00 00 00 00 00 00 F0 C2     //response,01,true, "Network supports acyclic data access"  52 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69  53 COM1 Read(hex): 19(Bytes) 20 01 03 01 00 01 01 04 00 01 00 00 00 00 00 00 00 CC 92  54  55  56  57 COM1 Write(hex): 19(Bytes)E0 01 03 01 00 41 00 03 00 02 01 01 00 00 00 00 00 ED 27     //03,00 01,00 03,get network object,Data format(LSB?MSB?)  58 COM1 Read(hex): 19(Bytes) A0 01 03 01 00 01 01 04 00 01 00 00 00 00 00 00 00 24 F3  59 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69  60 COM1 Read(hex): 19(Bytes) 20 01 03 01 00 01 01 04 00 01 00 00 00 00 00 00 00 CC 92  61 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08  62 COM1 Read(hex): 19(Bytes) E0 01 03 01 00 01 01 03 00 00 00 00 00 00 00 00 00 E6 B2     //response, 00,LSB first  63 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69  64 COM1 Read(hex): 19(Bytes) 20 01 03 01 00 01 01 03 00 00 00 00 00 00 00 00 00 DA E2  65  66  67  68 COM1 Write(hex): 19(Bytes)60 01 03 01 00 51 04 03 00 05 01 03 00 00 00 00 00 CE D2     //command 11,Map_ADI_Read_Area,4 bytes message data,ADI number 00 03;Data Type                                                       Of the ADI:05(UINT16);Number of elements in the ADI:01;Order Number of the                                                     ADI:00 03, 2 bytes  69 COM1 Read(hex): 19(Bytes) 20 01 03 01 00 01 01 03 00 00 00 00 00 00 00 00 00 DA E2  70 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08  71 COM1 Read(hex): 19(Bytes) A0 01 03 01 00 01 01 03 00 00 00 00 00 00 00 00 00 32 83  72 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69  73 COM1 Read(hex): 19(Bytes) 60 01 03 01 00 11 01 03 00 00 00 00 00 00 00 00 00 F1 12     //response,Offset of the mapped ADI from start of the Write Process Data:00 03  74 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08  75 COM1 Read(hex): 19(Bytes) A0 01 03 01 00 11 01 03 00 00 00 00 00 00 00 00 00 CD 42  76  77  78  79 COM1 Write(hex): 19(Bytes)E0 01 03 01 00 51 04 04 00 00 01 04 00 00 00 00 00 74 C3     //command 11,Map_ADI_Read_Area,4 bytes message data,ADI number 00 04;Data Type                                                       Of the ADI:00(BOOL8);Number of elements in the ADI:01;Order Number of the                                                     ADI:00 04, 1 byte 80 COM1 Read(hex): 19(Bytes) A0 01 03 01 00 11 01 03 00 00 00 00 00 00 00 00 00 CD 42  81 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69  82 COM1 Read(hex): 19(Bytes) 20 01 03 01 00 11 01 03 00 00 00 00 00 00 00 00 00 25 23  83 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08  84 COM1 Read(hex): 19(Bytes) E0 01 03 01 00 11 01 04 00 02 00 00 00 00 00 00 00 1A 43     //response,Offset of the mapped ADI from start of the Write Process Data:00 04   85 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69  86 COM1 Read(hex): 19(Bytes) 20 01 03 01 00 11 01 04 00 02 00 00 00 00 00 00 00 26 13  87  88  89  90 COM1 Write(hex): 19(Bytes)E0 01 03 01 00 50 04 01 00 05 01 01 00 00 00 00 00 CD EE     //command 10,Map_ADI_Write_Area,4 bytes message data,ADI number 00 01;Data Type                                               Of the ADI:05(UINT16);Number of elements in the ADI:01;Order Number of the                                                       ADI:00 01, 2 bytes  91 COM1 Read(hex): 19(Bytes) A0 01 03 01 00 11 01 04 00 02 00 00 00 00 00 00 00 CE 72  92 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69  93 COM1 Read(hex): 19(Bytes) 20 01 03 01 00 11 01 04 00 02 00 00 00 00 00 00 00 26 13  94 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08  95 COM1 Read(hex): 19(Bytes) E0 01 03 01 00 10 01 01 00 00 00 00 00 00 00 00 00 10 2F     //response,Offset of the mapped ADI from start of the Write Process Data:00 01  96 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69  97 COM1 Read(hex): 19(Bytes) 20 01 03 01 00 10 01 01 00 00 00 00 00 00 00 00 00 2C 7F  98  99 100 101 COM1 Write(hex): 19(Bytes)60 00 03 01 00 41 00 02 00 05 01 01 00 00 00 00 00 B6 97    //03,00 01,00 02, get Network type string  102 COM1 Read(hex): 19(Bytes) 20 01 03 01 00 10 01 01 00 00 00 00 00 00 00 00 00 2C 7F 103 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08 104 COM1 Read(hex): 19(Bytes) A0 01 03 01 00 10 01 01 00 00 00 00 00 00 00 00 00 C4 1E 105 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69 106 COM1 Read(hex): 19(Bytes) 60 00 03 01 00 01 09 02 00 44 65 76 69 63 65 4E 65 71 F5    //response with "DeviceNet",fragment1 107 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08 108 COM1 Read(hex): 19(Bytes) E0 74 03 01 00 01 09 02 00 44 65 76 69 63 65 4E 65 BE B3    //response with "DeviceNet",fragment2  109 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69 110 COM1 Read(hex): 19(Bytes) 20 74 03 01 00 01 09 02 00 44 65 76 69 63 65 4E 65 82 E3 111 112 113 114 COM1 Write(hex): 19(Bytes)60 01 01 01 00 41 00 02 00 05 01 01 00 00 00 00 00 27 D4     //01,00 01,00 02,get Firmware version 115 COM1 Read(hex): 19(Bytes) 20 74 03 01 00 01 09 02 00 44 65 76 69 63 65 4E 65 82 E3 116 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08 117 COM1 Read(hex): 19(Bytes) E0 01 01 01 00 01 03 02 00 02 04 01 69 63 65 4E 65 8B 08    //response 118 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69 119 COM1 Read(hex): 19(Bytes) 20 01 01 01 00 01 03 02 00 02 04 01 69 63 65 4E 65 B7 58 120 121 122  123 COM1 Write(hex): 19(Bytes)60 02 01 01 00 41 00 03 00 05 01 01 00 00 00 00 00 13 C5     //01,00 01,00 03,get Serial number 124 COM1 Read(hex): 19(Bytes) 20 01 01 01 00 01 03 02 00 02 04 01 69 63 65 4E 65 B7 58 125 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08 126 COM1 Read(hex): 19(Bytes) E0 02 01 01 00 01 04 03 00 A1 0E 13 A0 63 65 4E 65 C4 3C    //response 127 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69 128 COM1 Read(hex): 19(Bytes) 20 02 01 01 00 01 04 03 00 A1 0E 13 A0 63 65 4E 65 F8 6C129 130  131  132 COM1 Write(hex): 19(Bytes)60 03 04 01 00 42 01 05 00 01 01 01 00 00 00 00 00 94 20    //04,00 01,00 05,set 01 to MACID(DeviceNet address)133 COM1 Read(hex): 19(Bytes) 20 02 01 01 00 01 04 03 00 A1 0E 13 A0 63 65 4E 65 F8 6C 134 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08 135 COM1 Read(hex): 19(Bytes) A0 02 01 01 00 01 04 03 00 A1 0E 13 A0 63 65 4E 65 10 0D 136 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69 137 COM1 Read(hex): 19(Bytes) 20 02 01 01 00 01 04 03 00 A1 0E 13 A0 63 65 4E 65 F8 6C 138 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08 139 COM1 Read(hex): 19(Bytes) E0 03 04 01 00 02 00 05 00 A1 0E 13 A0 63 65 4E 65 7C C9    //response OK 140 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69141 COM1 Read(hex): 19(Bytes) 20 03 04 01 00 02 00 05 00 A1 0E 13 A0 63 65 4E 65 40 99 142 143 144 145 COM1 Write(hex): 19(Bytes)60 04 04 02 00 42 01 05 00 02 01 01 00 00 00 00 00 B0 21    //04,00 02,00 05,set 02 to Baudrate value(500K) 146 COM1 Read(hex): 19(Bytes) 20 03 04 01 00 02 00 05 00 A1 0E 13 A0 63 65 4E 65 40 99 147 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08 148 COM1 Read(hex): 19(Bytes) A0 03 04 01 00 02 00 05 00 A1 0E 13 A0 63 65 4E 65 A8 F8 149 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69 150 COM1 Read(hex): 19(Bytes) 60 04 04 02 00 02 00 05 00 A1 0E 13 A0 63 65 4E 65 A5 E9    //response OK 151 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08 152 COM1 Read(hex): 19(Bytes) A0 04 04 02 00 02 00 05 00 A1 0E 13 A0 63 65 4E 65 99 B9153 154 155  156 COM1 Write(hex): 19(Bytes)E0 05 01 01 00 42 01 05 00 01 01 01 00 00 00 00 00 DD 07     //set 01 to attr 05 inst 1 of Anybus object,indicate Setup complete 157 COM1 Read(hex): 19(Bytes) A0 04 04 02 00 02 00 05 00 A1 0E 13 A0 63 65 4E 65 99 B9 158 COM1 Write(hex): 19(Bytes)20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA 69 159 COM1 Read(hex): 19(Bytes) 60 05 01 01 00 02 00 05 00 A1 0E 13 A0 63 65 4E 65 35 EE    //response OK  160 COM1 Write(hex): 19(Bytes)A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 08 161 COM1 Read(hex): 19(Bytes) A0 05 01 01 00 02 00 05 00 A1 0E 13 A0 63 65 4E 65 09 BE 

 

驱动代码