Skip to content

Commit 6895857

Browse files
hdiethelmHannes Diethelm
authored andcommitted
Xenomai EVL network for Hostmot2: Enable port in initf
Requres: initf hm2_eth.realtime-init servo-thread in .hal file
1 parent 07a6683 commit 6895857

2 files changed

Lines changed: 35 additions & 4 deletions

File tree

src/hal/drivers/mesa-hostmot2/hm2_eth.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,16 @@ static int hm2_eth_items(hm2_eth_t *board) {
16561656
return 0;
16571657
}
16581658

1659+
static int num_boards = 0;
1660+
void init_board_realtime_all(void *arg, long period){
1661+
(void)arg;
1662+
(void)period;
1663+
int i;
1664+
for(i = 0; i<num_boards; i++) {
1665+
init_board_realtime(&boards[i]);
1666+
}
1667+
}
1668+
16591669
int rtapi_app_main(void) {
16601670
RTAPI_INIT_LIST_HEAD(&ifnames);
16611671
RTAPI_INIT_LIST_HEAD(&board_num);
@@ -1679,7 +1689,7 @@ int rtapi_app_main(void) {
16791689
if (ret < 0)
16801690
goto error;
16811691

1682-
int num_boards = i;
1692+
num_boards = i;
16831693
comm_active = 1;
16841694

16851695
for(i = 0; i<num_boards; i++)
@@ -1704,9 +1714,7 @@ int rtapi_app_main(void) {
17041714
*added = 1;
17051715
}
17061716

1707-
for(i = 0; i<num_boards; i++) {
1708-
init_board_realtime(&boards[i]);
1709-
}
1717+
hal_export_functf(init_board_realtime_all, 0, 0, 0, comp_id, "%s.realtime-init", HM2_LLIO_NAME);
17101718

17111719
hal_ready(comp_id);
17121720

src/hal/drivers/mesa-hostmot2/hm2_eth_net_evl.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,27 @@ static void print_addr(char* desc, struct sockaddr_in *addr){
232232
}
233233
*/
234234

235+
static int check_evl(hm2_eth_t *board){
236+
static bool error_shown = false;
237+
if(!board->is_evl_oob_active && evl_get_self() >= 0){
238+
if(!error_shown){
239+
LL_PRINT("ERROR: hm2_eth evl mode: OOB not active in realtime thread\n"
240+
" Please add: initf hm2_eth.realtime-init servo-thread\n"
241+
" to your hal file\n");
242+
error_shown = true;
243+
}
244+
return -1;
245+
}else{
246+
return 0;
247+
}
248+
}
249+
235250
int hm2_evl_eth_socket_send(hm2_eth_t *board, const void *buffer, int len, int flags){
236251
ssize_t ret = 0;
252+
ret = check_evl(board);
253+
if(ret < 0){
254+
return ret;
255+
}
237256
if(board->is_evl_oob_active){
238257
struct iovec iov;
239258
struct oob_msghdr msghdr;
@@ -270,6 +289,10 @@ int hm2_evl_eth_socket_send(hm2_eth_t *board, const void *buffer, int len, int f
270289

271290
int hm2_evl_eth_socket_recv(hm2_eth_t *board, void *buffer, int len, int flags){
272291
ssize_t ret = 0;
292+
ret = check_evl(board);
293+
if(ret < 0){
294+
return ret;
295+
}
273296
if(board->is_evl_oob_active){
274297
struct oob_msghdr msghdr;
275298
struct iovec iov;

0 commit comments

Comments
 (0)