Comments (10)
Hello,
it is doing all networks stuff in network.c I guess.
I changed network.c a bit from original libartnet source because it was not working OSX.
the problem of original network.c in OSX was that the method of getting network interface ip addresses, get_ifaces(), couldn't be compiled.
I am not sure the original file will work on linux.
I cant remember more detail about when i changed the source,
but i found i had deleted some features which is may for linux by doing diff original and this network.c.
just try below get_ifaces() which is from original source for linux or i recommend you do diff network.c by yourself.
https://code.google.com/p/open-lighting/downloads/detail?name=libartnet-1.1.1.tar.gz&can=2&q=
thanks,
#else // no GETIFADDRS
/*
-
Set if_head to point to a list of iface_t structures which represent the
-
interfaces on this machine
-
@param ift_head the address of the pointer to the head of the list
_/
static int get_ifaces(iface_t *_if_head) {
struct ifconf ifc;
struct ifreq *ifr, ifrcopy;
struct sockaddr_in *sin;
int len, lastlen, flags;
char *buf, *ptr;
iface_t *if_tail, *iface;
int ret = ARTNET_EOK;
int sd;*if_head = if_tail = NULL;
// create socket to get iface config
sd = socket(PF_INET, SOCK_DGRAM, 0);if (sd < 0) {
artnet_error("%s : Could not create socket %s", FUNCTION, strerror(errno));
ret = ARTNET_ENET;
goto e_return;
}// first use ioctl to get a listing of interfaces
lastlen = 0;
len = INITIAL_IFACE_COUNT * sizeof(struct ifreq);for (;;) {
buf = malloc(len);if (buf == NULL) {
artnet_error_malloc();
ret = ARTNET_EMEM;
goto e_free;
}ifc.ifc_len = len;
ifc.ifc_buf = buf;
if (ioctl(sd, SIOCGIFCONF, &ifc) < 0) {
if (errno != EINVAL || lastlen != 0) {
artnet_error("%s : ioctl error %s", FUNCTION, strerror(errno));
ret = ARTNET_ENET;
goto e_free;
}
} else {
if (ifc.ifc_len == lastlen)
break;
lastlen = ifc.ifc_len;
}
len += IFACE_COUNT_INC * sizeof(struct ifreq);
free(buf);
}// loop through each iface
for (ptr = buf; ptr < buf + ifc.ifc_len;) {
ifr = (struct ifreq*) ptr;// work out length here
#ifdef HAVE_SOCKADDR_SA_LEN
len = max(sizeof(struct sockaddr), ifr->ifr_addr.sa_len);
#else
switch (ifr->ifr_addr.sa_family) {
#ifdef IPV6
case AF_INET6:
len = sizeof(struct sockaddr_in6);
break;
#endif
case AF_INET:
default:
len = sizeof(SA);
break;
}
#endifptr += sizeof(ifr->ifr_name) + len;
// look for AF_INET interfaces
if (ifr->ifr_addr.sa_family == AF_INET) {
ifrcopy = *ifr;
if (ioctl(sd, SIOCGIFFLAGS, &ifrcopy) < 0) {
artnet_error("%s : ioctl error %s" , FUNCTION, strerror(errno));
ret = ARTNET_ENET;
goto e_free_list;
}flags = ifrcopy.ifr_flags;
if ((flags & IFF_UP) == 0)
continue; //skip down interfacesif ((flags & IFF_LOOPBACK))
continue; //skip lookbackiface = new_iface(if_head, &if_tail);
if (!iface)
goto e_free_list;sin = (struct sockaddr_in *) &ifr->ifr_addr;
iface->ip_addr.sin_addr = sin->sin_addr;// fetch bcast address
#ifdef SIOCGIFBRDADDR
if (flags & IFF_BROADCAST) {
if (ioctl(sd, SIOCGIFBRDADDR, &ifrcopy) < 0) {
artnet_error("%s : ioctl error %s" , FUNCTION, strerror(errno));
ret = ARTNET_ENET;
goto e_free_list;
}sin = (struct sockaddr_in *) &ifrcopy.ifr_broadaddr; iface->bcast_addr.sin_addr = sin->sin_addr;
}
#endif
// fetch hardware address
#ifdef SIOCGIFHWADDR
if (flags & SIOCGIFHWADDR) {
if (ioctl(sd, SIOCGIFHWADDR, &ifrcopy) < 0) {
artnet_error("%s : ioctl error %s", FUNCTION, strerror(errno));
ret = ARTNET_ENET;
goto e_free_list;
}
memcpy(&iface->hw_addr, ifrcopy.ifr_hwaddr.sa_data, ARTNET_MAC_SIZE);
}
#endif/* ok, if that all failed we should prob try and use sysctl to work out the bcast
- and hware addresses
- i'll leave that for another day
*/
}
}
free(buf);
close(sd);
return ARTNET_EOK;
e_free_list:
free_ifaces(*if_head);
e_free:
free(buf);
close(sd);
e_return:
return ret;
}
#endif // GETIFADDRS
from ofxartnet.
thanks
just solve it with fishkingsin@b1ccc37
//custermized by horristic
#ifndef WIN32
//modified by James Kong
#ifdef TARGET_LINUX_ARM
#include <ifaddrs.h>
#include <net/if_types.h>
#include <net/if_dl.h>
#else
//support RaspberryPi
#include <ifaddrs.h>
#endif
#endif
from ofxartnet.
nice to hear that.
if you fix some code, can you send me pull request?
from ofxartnet.
but I refactored artnet folder
and used OF Specific marco definition #define TARGET_LINUX_ARM
in network.c
seems it is not a good habit
Let checkthe pull request
and let us discuss more further
from ofxartnet.
sent with pull request
from ofxartnet.
I have no idea what you changed in your code.
Could you find net/if_types.h in your linux machine??
About macro, i found another way to detect the type of OS.
Does this work in your linux?
http://stackoverflow.com/questions/5919996/how-to-detect-reliably-mac-os-x-ios-linux-windows-in-c-preprocessor
from ofxartnet.
umm...
I found that even if i comment
#include <net/if_types.h> #include <net/if_dl.h>
in network.c at lin 50, 51
it still can be compiled on Mac osx
please double check if it is necessary on osx
mine is osx 10.7 Mac Pro
thanks
from ofxartnet.
I added some code for support windows. now it is working OSX10.8.2 and windows7.
Could you please try to run multiOS branch at your RP?
https://github.com/hiroyuki/ofxArtnet/tree/multiOS
thanks,
from ofxartnet.
sorry for my typing mistake
exclude
#include <net/if_types.h> #include <net/if_dl.h>
from network.c
#4
for the correction
the header should be like this
#ifdef _WIN32
#include "unistd_d.h"
#include <windows.h>
#endif
#ifdef __unix
#include <ifaddrs.h>
#endif
#ifdef __APPLE__
#include <ifaddrs.h>
#include <unistd.h>
#endif
also could you change the macros in standard way of the sources
thanks
from ofxartnet.
sweet.
thank you James.
I merged that!!
from ofxartnet.
Related Issues (20)
- using another universe HOT 4
- Failed to start: Failed to bind to socket Address already in use HOT 4
- Suggestion: it would be great to be able to create a Map or Vector of ofxArtnet HOT 1
- possibility to run setup again in an ofxArtnet object HOT 2
- Addressing more than one universe HOT 1
- fail to work on windows10 HOT 1
- Please return a bool in setup() HOT 1
- Logo link broken in readme.md HOT 1
- Does not compile anymore. HOT 1
- possibility of sendArtnet receive other kinds of data, like unsigned char HOT 3
- how to send data to multiple universes HOT 10
- No way of checking if ofxArtnetSender/Receiver is actually connected HOT 6
- RPI HOT 2
- Artnet Receive doesn't output the correct universe number HOT 2
- Add Support for Broadcast HOT 1
- ofxArtnetMessage setData size issue HOT 3
- 100% CPU core with ofxUDPManager set at non-blocking
- Data message gets truncated
- Dropping frames / Low framerate
- Receiving ArtNet from multiple universes? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ofxartnet.