在VxWorks 6.8上获取MAC地址
我正试图解决这个问题,但在VxWorks 6.8上获取MAC地址时遇到了困难 使用在VxWorks 6.8上获取MAC地址,c,networking,microcontroller,mac-address,vxworks,C,Networking,Microcontroller,Mac Address,Vxworks,我正试图解决这个问题,但在VxWorks 6.8上获取MAC地址时遇到了困难 使用muxIoctl()我没有得到正确的结果: /* Binding the cookie */ PROTO_COOKIE muxCookie = muxBind( ... ); /* Binding network service <-> end */ /* * Error handling etc. * [...] */ /* Getting the the address */ char r
muxIoctl()
我没有得到正确的结果:
/* Binding the cookie */
PROTO_COOKIE muxCookie = muxBind( ... ); /* Binding network service <-> end */
/*
* Error handling etc.
* [...]
*/
/* Getting the the address */
char result[6];
STATUS status = muxIoctl(muxCookie, EIOCGADDR, result); /* ioctl the device address */
if( status != OK )
{
/* Error handling */
}
else
{
/* ioctl() was Ok, print 'result' */
}
两个设备都有一个有效的MAC地址,这可以通过ifconfig
或在传输的数据包中看到。接口(如上所述)良好且工作正常
通过muxDevAcquire()
(或deprcatedendFindByName()
)获取cookie,而不是直接使用muxBind()
中的一个,具有相同的结果
此外:muxDevExists()
返回TRUE
,另一个“黑客”代码也不起作用(但它返回的值如上所述):
顺便说一句,在同一位置对muxIoctl()
的其他控件工作正常
上面提到的设备使用的dtsec也工作正常,但有一个例外:相关的dtsecEndIoctl()
-底层ioctl()
到muxIoctl()
委托-没有设置地址!它只在系统启动时执行一次操作(否则它会复制上面的字节)
由于dtsecEndIoctl()
的EIOCGADDR
只不过是pDrvCtrl->dtsecAddr
中的bcopy()
(pDrvCtrl
=muxCookie
转换为DTSEC\u DRV\u CTRL*
!)在我看来,这就像是muxCookie
的问题。然而,cookie在任何时候、任何地方都能正常工作——这在这里是意料之中的(旁注:尚未在etsec上测试)
详细解释,简短问题:如何解决此问题,以及如何获得MAC地址
解决此问题的其他讨论:
[更新]:在etsec上
muxIoctl()
使用正确的MAC,在dtsec上,wit如上所述失败。看起来dtsecEndIoctl工作不正常。
在终端驱动程序中,END->pFuncTable->ioctl的地址是dtsecEndIoctl。
这意味着如果dtsecEndIoctl的EIOCGADDR
正确复制MAC,则end->pFuncTable->ioctl正确复制MAC
Device #1: 00 00 00 00 0A 00
Device #2: 00 00 00 00 0B 00
^
|
Every byte is 0, with the exception of these
const char* devName = ...
int unit = ...
char result[6];
END_OBJ* end = endFindByName(devName, unit);
STATUS status = end->pFuncTable->ioctl(end, EIOCGADDR, result);