erika/oshw.c
Go to the documentation of this file.
1 /*
2  * Licensed under the GNU General Public License version 2 with exceptions. See
3  * LICENSE file in the project root for full license information
4  */
5 
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <inttypes.h>
10 
11 #include "oshw.h"
12 #include "intel_i210.h"
13 #include "ethercat.h"
14 
15 #if !defined(__gnu_linux__)
16 #include <machine/endian.h>
17 #else
18 #include <endian.h>
19 #define __htons(x) htobe16(x)
20 #define __ntohs(x) be16toh(x)
21 #endif
22 
23 ec_adaptert adapters [DEVS_MAX_NB];
24 
31 inline uint16 oshw_htons(uint16 host)
32 {
33  // __htons() is provided by the bare-metal x86 compiler
34  return __htons(host);
35 }
36 
43 inline uint16 oshw_ntohs(uint16 network)
44 {
45  // __ntohs() is provided by the bare-metal x86 compiler
46  return __ntohs(network);
47 }
48 
53 {
54  ec_adaptert *ret = NULL;
55  if (eth_discover_devices() >= 0) {
56  for (int i = 0;; ++i) {
57  struct eth_device *dev = eth_get_device(i);
58  if (dev == NULL) {
59  adapters[i-1].next = NULL;
60  break;
61  }
62  strncpy(adapters[i].name, dev->name, MAX_DEVICE_NAME);
63  adapters[i].next = &adapters[i+1];
64  }
65  ret = &(adapters[0]);
66  }
67  return ret;
68 }
69 
75 {
76 }
77 
78 extern int ec_slavecount;
79 
ec_adapter
Definition: ethercatmain.h:44
ethercat.h
Headerfile for all ethercat headers.
oshw_htons
uint16 oshw_htons(uint16 host)
Definition: erika/oshw.c:31
ec_adapter::next
ec_adaptert * next
Definition: ethercatmain.h:48
oshw.h
Headerfile for ethercatbase.c.
uint16
uint16_t uint16
Definition: osal.h:29
oshw_ntohs
uint16 oshw_ntohs(uint16 network)
Definition: erika/oshw.c:43
oshw_free_adapters
void oshw_free_adapters(ec_adaptert *adapter)
Definition: erika/oshw.c:74
adapters
ec_adaptert adapters[DEVS_MAX_NB]
Definition: erika/oshw.c:23
ec_slavecount
int ec_slavecount
Definition: ethercatmain.c:69
oshw_find_adapters
ec_adaptert * oshw_find_adapters(void)
Definition: erika/oshw.c:52
ec_adapter::name
char name[EC_MAXLEN_ADAPTERNAME]
Definition: ethercatmain.h:46
inttypes.h


soem
Author(s): Arthur Ketels and M.J.G. van den Molengraft
autogenerated on Wed Mar 2 2022 01:01:49