I've now pushed jepler/hm2-eth-v3. I believe this new spin addresses
the feedback items (aside from "true tram", which we've set aside for
now). It also resolves some compiler diagnostics in hm2_eth that
bugged me, mostly by checking return values and printing errors when
something goes wrong.
I enclose a diff between v2 and v3.
Jeff
diff --git a/src/hal/drivers/mesa-hostmot2/hm2_eth.c
b/src/hal/drivers/mesa-hostmot2/hm2_eth.c
index 92b8e59..9ebbe4f 100644
--- a/src/hal/drivers/mesa-hostmot2/hm2_eth.c
+++ b/src/hal/drivers/mesa-hostmot2/hm2_eth.c
@@ -156,7 +156,7 @@ static int eth_socket_recv(int sockfd, void *buffer, int
len, int flags) {
static int hm2_eth_read(hm2_lowlevel_io_t *this, rtapi_u32 addr, void *buffer,
int size) {
int send, recv, i = 0;
rtapi_u8 tmp_buffer[size + 4];
- long long t0, t1, t2;
+ long long t1, t2;
if (comm_active == 0) return 1;
if (size == 0) return 1;
@@ -164,8 +164,9 @@ static int hm2_eth_read(hm2_lowlevel_io_t *this, rtapi_u32
addr, void *buffer, i
LBP16_INIT_PACKET4(read_packet, CMD_READ_HOSTMOT2_ADDR32_INCR(size/4),
addr & 0xFFFF);
- t0 = rtapi_get_time();
send = eth_socket_send(sockfd, (void*) &read_packet, sizeof(read_packet),
0);
+ if(send < 0)
+ LL_PRINT("ERROR: sending packet: %s\n", strerror(errno));
LL_PRINT_IF(debug, "read(%d) : PACKET SENT [CMD:%02X%02X | ADDR: %02X%02X
| SIZE: %d]\n", read_cnt, read_packet.cmd_hi, read_packet.cmd_lo,
read_packet.addr_lo, read_packet.addr_hi, size);
t1 = rtapi_get_time();
@@ -192,12 +193,13 @@ static int hm2_eth_enqueue_read(hm2_lowlevel_io_t *this,
rtapi_u32 addr, void *b
if (size == 0) return 1;
if (size == -1) {
int send, recv, i = 0;
- long long t0, t1, t2;
+ long long t1, t2;
rtapi_u8 tmp_buffer[queue_buff_size];
read_cnt++;
- t0 = rtapi_get_time();
send = eth_socket_send(sockfd, (void*) &queue_packets,
sizeof(lbp16_cmd_addr)*queue_reads_count, 0);
+ if(send < 0)
+ LL_PRINT("ERROR: sending packet: %s\n", strerror(errno));
t1 = rtapi_get_time();
do {
rtapi_delay(10000);
@@ -239,6 +241,8 @@ static int hm2_eth_write(hm2_lowlevel_io_t *this, rtapi_u32
addr, void *buffer,
LBP16_INIT_PACKET4(packet.wr_packet,
CMD_WRITE_HOSTMOT2_ADDR32_INCR(size/4), addr & 0xFFFF);
send = eth_socket_send(sockfd, (void*) &packet, sizeof(lbp16_cmd_addr) +
size, 0);
+ if(send < 0)
+ LL_PRINT("ERROR: sending packet: %s\n", strerror(errno));
LL_PRINT_IF(debug, "write(%d): PACKET SENT [CMD:%02X%02X | ADDR: %02X%02X
| SIZE: %d]\n", write_cnt, packet.wr_packet.cmd_hi, packet.wr_packet.cmd_lo,
packet.wr_packet.addr_lo, packet.wr_packet.addr_hi, size);
@@ -255,6 +259,8 @@ static int hm2_eth_enqueue_write(hm2_lowlevel_io_t *this,
rtapi_u32 addr, void *
write_cnt++;
t0 = rtapi_get_time();
send = eth_socket_send(sockfd, (void*) &write_packet,
write_packet_size, 0);
+ if(send < 0)
+ LL_PRINT("ERROR: sending packet: %s\n", strerror(errno));
t1 = rtapi_get_time();
LL_PRINT_IF(debug, "enqueue_write(%d) : PACKET SEND [SIZE: %d | TIME:
%llu]\n", write_cnt, send, t1 - t0);
write_packet_ptr = &write_packet;
@@ -275,15 +281,17 @@ static void hm2_eth_probe() {
int ret, send, recv;
char board_name[16] = {0, };
char llio_name[16] = {0, };
- hm2_lowlevel_io_t *this;
hm2_eth_t *board;
LBP16_INIT_PACKET4(read_packet, CMD_READ_BOARD_INFO_ADDR16_INCR(16/2), 0);
send = eth_socket_send(sockfd, (void*) &read_packet, sizeof(read_packet),
0);
+ if(send < 0)
+ LL_PRINT("ERROR: sending packet: %s\n", strerror(errno));
recv = eth_socket_recv(sockfd, (void*) &board_name, 16, 0);
+ if(recv < 0)
+ LL_PRINT("ERROR: receiving packet: %s\n", strerror(errno));
board = &boards[boards_count];
- this = &board->llio;
if (strncmp(board_name, "7I80DB-16", 9) == 0) {
strncpy(llio_name, board_name, 4);
diff --git a/src/hal/drivers/mesa-hostmot2/hostmot2-lowlevel.h
b/src/hal/drivers/mesa-hostmot2/hostmot2-lowlevel.h
index 217ffb2..e34500b 100644
--- a/src/hal/drivers/mesa-hostmot2/hostmot2-lowlevel.h
+++ b/src/hal/drivers/mesa-hostmot2/hostmot2-lowlevel.h
@@ -114,7 +114,7 @@ struct hm2_lowlevel_io_struct {
int threadsafe;
void *private; // for the low-level driver to hang their struct on
-} __attribute__ ((__packed__));
+};
diff --git a/src/hal/drivers/mesa-hostmot2/tram.c
b/src/hal/drivers/mesa-hostmot2/tram.c
index 02b9a18..7b7e173 100644
--- a/src/hal/drivers/mesa-hostmot2/tram.c
+++ b/src/hal/drivers/mesa-hostmot2/tram.c
@@ -151,6 +151,8 @@ int hm2_tram_read(hostmot2_t *hm2) {
}
if (!hm2->llio->queue_read(hm2->llio, 0, NULL, -1)) {
+ HM2_ERR("TRAM read error finishing read! iter=%u)\n",
+ tram_read_iteration);
}
tram_read_iteration ++;
@@ -172,6 +174,8 @@ int hm2_tram_write(hostmot2_t *hm2) {
}
if (!hm2->llio->queue_write(hm2->llio, 0, NULL, -1)) {
+ HM2_ERR("TRAM write error finishing write! iter=%u)\n",
+ tram_write_iteration);
}
tram_write_iteration ++;
diff --git a/src/hal/drivers/mesa-hostmot2/watchdog.c
b/src/hal/drivers/mesa-hostmot2/watchdog.c
index a4ae5ff..f98ca3f 100644
--- a/src/hal/drivers/mesa-hostmot2/watchdog.c
+++ b/src/hal/drivers/mesa-hostmot2/watchdog.c
@@ -101,7 +101,6 @@ void hm2_watchdog_process_tram_read(hostmot2_t *hm2) {
// last time we were here, everything was fine
// see if the watchdog has bit since then
- if ((*hm2->llio->io_error) != 0) return;
if (hm2->watchdog.status_reg[0] & 0x1) {
HM2_PRINT("Watchdog has bit! (set the .has-bit pin to False to
resume)\n");
*hm2->watchdog.instance[0].hal.pin.has_bit = 1;
@@ -259,7 +258,6 @@ fail2:
rtapi_kfree(hm2->watchdog.reset_reg);
fail1:
- rtapi_kfree(hm2->watchdog.status_reg);
fail0:
hm2->watchdog.num_instances = 0;
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers