wireless/ieee802154: Use new IOCTL data definitions.

This commit is contained in:
Gregory Nutt 2017-04-13 08:57:26 -06:00
parent 920b060878
commit 674e081b55
10 changed files with 93 additions and 33 deletions

View File

@ -1,6 +1,7 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_getcca.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
@ -52,11 +53,15 @@
int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca)
{
int ret = ioctl(fd, PHY802154IOC_GET_CCA, (unsigned long)cca );
union ieee802154_radioarg_u arg;
int ret = ioctl(fd, PHY802154IOC_GET_CCA,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_GET_CCA failed\n");
}
mempy(cca, &arg.cca, sizeof(struct ieee802154_cca_s));
return ret;
}

View File

@ -1,6 +1,7 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_getchan.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
@ -52,11 +53,16 @@
int ieee802154_getchan(int fd, FAR uint8_t *chan)
{
int ret = ioctl(fd, PHY802154IOC_GET_CHAN, (unsigned long)chan);
union ieee802154_radioarg_u arg;
int ret = ioctl(fd, PHY802154IOC_GET_CHAN,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_GET_CHAN failed\n");
return ret;
}
*chan = arg.channel;
return ret;
}

View File

@ -1,6 +1,7 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_setchan.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
@ -52,7 +53,12 @@
int ieee802154_setcca(int fd, FAR struct ieee802154_cca_s *cca)
{
int ret = ioctl(fd, PHY802154IOC_SET_CCA, (unsigned long)cca );
union ieee802154_radioarg_u arg;
mempy(&arg.cca, cca, sizeof(struct ieee802154_cca_s));
int ret = ioctl(fd, PHY802154IOC_SET_CCA,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_SET_CCA failed\n");

View File

@ -1,6 +1,7 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_setchan.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
@ -51,7 +52,12 @@
int ieee802154_setchan(int fd, uint8_t chan)
{
int ret = ioctl(fd, PHY802154IOC_SET_CHAN, (unsigned long)chan );
union ieee802154_radioarg_u arg;
arg.channel = chan;
int ret = ioctl(fd, PHY802154IOC_SET_CHAN,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_SET_CHAN failed\n");

View File

@ -1,6 +1,7 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_setdevmode.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
@ -51,7 +52,12 @@
int ieee802154_setdevmode(int fd, uint8_t devmode)
{
int ret = ioctl(fd, PHY802154IOC_SET_DEVMODE, (unsigned long)devmode );
union ieee802154_radioarg_u arg;
arg.devmode = devmode;
int ret = ioctl(fd, PHY802154IOC_SET_DEVMODE,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_SET_DEVMODE failed\n");

View File

@ -1,6 +1,7 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_eaddr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
@ -51,7 +52,12 @@
int ieee802154_seteaddr(int fd, uint8_t *eaddr)
{
int ret = ioctl(fd, PHY802154IOC_SET_EADDR, (unsigned long)eaddr );
union ieee802154_radioarg_u arg;
memcpy(arg.eaddr, eaddr, EADDR_SIZE);
int ret = ioctl(fd, PHY802154IOC_SET_EADDR,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_SET_EADDR failed\n");

View File

@ -1,6 +1,7 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_setpanid.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
@ -47,7 +48,12 @@
int ieee802154_setpanid(int fd, uint16_t panid)
{
int ret = ioctl(fd, PHY802154IOC_SET_PANID, (unsigned long)panid );
union ieee802154_radioarg_u arg;
arg.panid = panid;
int ret = ioctl(fd, PHY802154IOC_SET_PANID,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_SET_PANID failed\n");

View File

@ -1,6 +1,7 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_setpromisc.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
@ -52,7 +53,12 @@
int ieee802154_setpromisc(int fd, bool promisc)
{
int ret = ioctl(fd, PHY802154IOC_SET_PROMISC, (unsigned long)promisc );
union ieee802154_radioarg_u arg;
arg.promisc = promisc;
int ret = ioctl(fd, PHY802154IOC_SET_PROMISC,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_SET_PROMISC failed\n");

View File

@ -1,6 +1,7 @@
/****************************************************************************
* apps/wireless/ieee802154/common/ieee802154_setsaddr.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
@ -51,7 +52,12 @@
int ieee802154_setsaddr(int fd, uint16_t saddr)
{
int ret = ioctl(fd, PHY802154IOC_SET_SADDR, (unsigned long)saddr );
union ieee802154_radioarg_u arg;
arg.saddr = saddr;
int ret = ioctl(fd, PHY802154IOC_SET_SADDR,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("PHY802154IOC_SET_SADDR failed\n");

View File

@ -2,7 +2,7 @@
* apps/wireless/ieee802154/i8sak/i8sak_main.c
* IEEE 802.15.4 Swiss Army Knife
*
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
@ -94,8 +94,10 @@ uint8_t g_disp[16];
int energy_scan(int fd)
{
union ieee802154_radioarg_u arg;
uint8_t chan;
uint8_t energy;
int ret = OK;
uint8_t chan, energy;
printf("\n");
@ -114,14 +116,15 @@ int energy_scan(int fd)
return ret;
}
ret = ioctl(fd, PHY802154IOC_ENERGYDETECT, (unsigned long)&energy);
ret = ioctl(fd, PHY802154IOC_ENERGYDETECT,
(unsigned long)((uintptr_t)&arg));
if (ret < 0)
{
printf("Device is not an IEEE 802.15.4 interface!\n");
return ret;
}
g_levels[chan] = energy;
g_levels[chan] = arg.energy;
}
/* Compute max with decay */
@ -146,7 +149,7 @@ int energy_scan(int fd)
printf("%2d : [%3d] ",chan+11, g_disp[chan]);
energy = g_disp[chan] >> 3;
while(energy-- > 0)
while (energy-- > 0)
{
printf("#");
}
@ -171,63 +174,66 @@ int energy_scan(int fd)
static int status(int fd)
{
int ret,i;
uint8_t chan, eaddr[8];
uint16_t panid, saddr;
bool promisc;
union ieee802154_radioarg_u arg;
struct ieee802154_cca_s cca;
uint8_t eaddr[EADDR_SIZE];
uint8_t chan;
uint16_t panid;
uint16_t saddr;
bool promisc;
int ret;
int i;
/* Get information */
ret = ioctl(fd, PHY802154IOC_GET_PANID, (unsigned long)&panid);
ret = ioctl(fd, PHY802154IOC_GET_PANID, (unsigned long)((uintptr_t)&arg));
if (ret)
{
printf("PHY802154IOC_GET_PANID failed\n");
return ret;
}
panid = arg.panid;
ret = ieee802154_getchan(fd, &chan);
if (ret)
{
return ret;
}
ret = ioctl(fd, PHY802154IOC_GET_SADDR, (unsigned long)&saddr);
ret = ioctl(fd, PHY802154IOC_GET_SADDR, (unsigned long)((uintptr_t)&arg));
if (ret)
{
printf("PHY802154IOC_GET_SADDR failed\n");
return ret;
}
ret = ioctl(fd, PHY802154IOC_GET_EADDR, (unsigned long)&eaddr[0]);
saddr = arg.saddr;
ret = ioctl(fd, PHY802154IOC_GET_EADDR, (unsigned long)((uintptr_t)&arg));
if (ret)
{
printf("PHY802154IOC_GET_EADDR failed\n");
return ret;
}
ret = ioctl(fd, PHY802154IOC_GET_PROMISC, (unsigned long)&promisc);
memcpy(eaddr, arg.eaddr, EADDR_SIZE);
ret = ioctl(fd, PHY802154IOC_GET_PROMISC, (unsigned long)((uintptr_t)&arg));
if (ret)
{
printf("PHY802154IOC_GET_PROMISC failed\n");
return ret;
}
promisc = arg.promisc;
ret = ieee802154_getcca(fd, &cca);
if (ret)
{
return ret;
}
#if 0
ret = ioctl(fd, MAC854IOCGORDER, (unsigned long)&order);
if (ret)
{
printf("MAC854IOCGORDER failed\n");
return ret;
}
#endif
/* Display */
printf("PANID %02X%02X CHAN %2d (%d MHz)\nSADDR %02X%02X EADDR ",
@ -422,10 +428,11 @@ int main(int argc, FAR char *argv[])
int i8_main(int argc, char *argv[])
#endif
{
union ieee802154_radioarg_u arg;
struct ieee802154_cca_s cca;
unsigned long arg = 0;
int fd;
int ret = OK;
unsigned long arg=0;
struct ieee802154_cca_s cca;
printf("IEEE packet sniffer/dumper argc=%d\n", argc);