diff --git a/src/devices/machine/k056230.cpp b/src/devices/machine/k056230.cpp index ae7c8625d0b7c..d6529bafb5e5b 100644 --- a/src/devices/machine/k056230.cpp +++ b/src/devices/machine/k056230.cpp @@ -197,12 +197,19 @@ void k056230_device::comm_tick() { if (m_linkenable == 0x01) { + std::error_condition filerr; + // check rx socket if (!m_line_rx) { osd_printf_verbose("k056230: listen on %s\n", m_localhost); uint64_t filesize; // unused - osd_file::open(m_localhost, OPEN_FLAG_CREATE, m_line_rx, filesize); + filerr = osd_file::open(m_localhost, OPEN_FLAG_CREATE, m_line_rx, filesize); + if (filerr.value() != 0) + { + osd_printf_verbose("k056230: rx connection failed\n"); + m_line_rx.reset(); + } } // check tx socket @@ -210,7 +217,12 @@ void k056230_device::comm_tick() { osd_printf_verbose("k056230: connect to %s\n", m_remotehost); uint64_t filesize; // unused - osd_file::open(m_remotehost, 0, m_line_tx, filesize); + filerr = osd_file::open(m_remotehost, 0, m_line_tx, filesize); + if (filerr.value() != 0) + { + osd_printf_verbose("k056230: tx connection failed\n"); + m_line_tx.reset(); + } } // if both sockets are there check ring @@ -312,9 +324,17 @@ int k056230_device::read_frame(int dataSize) togo -= recv; offset += recv; } - else if (filerr && filerr.value() != 0) + switch (filerr.value()) { - togo = 0; + case 0x00: + case 0x8c: + // 00 - no error + // 8c - unknown error (read behind eof?) + break; + + default: + togo = 0; + break; } } } @@ -323,8 +343,10 @@ int k056230_device::read_frame(int dataSize) { case 0x00: case 0x8c: + // 00 - no error + // 8c - unknown error (read behind eof?) break; - + default: osd_printf_verbose("k056230: rx connection lost %08x %s\n", filerr.value(), filerr.message()); m_line_rx.reset(); @@ -342,7 +364,7 @@ void k056230_device::send_frame(int dataSize) std::uint32_t written; filerr = m_line_tx->write(&m_buffer0, 0, dataSize, written); - if (filerr && filerr.value() != 0) + if (filerr.value() != 0) { osd_printf_verbose("k056230: tx connection lost %08x %s\n", filerr.value(), filerr.message()); m_line_tx.reset(); diff --git a/src/mame/sega/m1comm.cpp b/src/mame/sega/m1comm.cpp index 6771229dc9250..62504e8cb6f3a 100644 --- a/src/mame/sega/m1comm.cpp +++ b/src/mame/sega/m1comm.cpp @@ -315,6 +315,8 @@ void m1comm_device::comm_tick() { if (m_linkenable == 0x01) { + std::error_condition filerr; + int frameStart = 0x0010; int frameOffset = 0x0000; int frameSize = 0x01c4; @@ -342,7 +344,12 @@ void m1comm_device::comm_tick() { osd_printf_verbose("M1COMM: listen on %s\n", m_localhost); uint64_t filesize; // unused - osd_file::open(m_localhost, OPEN_FLAG_CREATE, m_line_rx, filesize); + filerr = osd_file::open(m_localhost, OPEN_FLAG_CREATE, m_line_rx, filesize); + if (filerr.value() != 0) + { + osd_printf_verbose("M1COMM: rx connection failed\n"); + m_line_rx.reset(); + } } // check tx socket @@ -350,7 +357,12 @@ void m1comm_device::comm_tick() { osd_printf_verbose("M1COMM: connect to %s\n", m_remotehost); uint64_t filesize; // unused - osd_file::open(m_remotehost, 0, m_line_tx, filesize); + filerr = osd_file::open(m_remotehost, 0, m_line_tx, filesize); + if (filerr.value() != 0) + { + osd_printf_verbose("M1COMM: tx connection failed\n"); + m_line_tx.reset(); + } } // if both sockets are there check ring @@ -581,26 +593,39 @@ int m1comm_device::read_frame(int dataSize) togo -= recv; offset += recv; } - else if (!filerr && recv == 0) + switch (filerr.value()) { - togo = 0; + case 0x00: + case 0x8c: + // 00 - no error + // 8c - unknown error (read behind eof?) + break; + + default: + togo = 0; + break; } } } } - else if (!filerr && recv == 0) + switch (filerr.value()) { - if (m_linkalive == 0x01) - { - osd_printf_verbose("M1COMM: rx connection lost\n"); - m_linkalive = 0x02; - m_linktimer = 0x00; - - m_shared[0] = 0xff; + case 0x00: + case 0x8c: + // 00 - no error + // 8c - unknown error (read behind eof?) + break; + default: + osd_printf_verbose("M1COMM: rx connection lost\n"); m_line_rx.reset(); - m_line_tx.reset(); - } + if (m_linkalive == 0x01) + { + m_linkalive = 0x02; + m_linktimer = 0x00; + m_shared[0] = 0xff; + } + break; } return recv; } @@ -623,18 +648,15 @@ void m1comm_device::send_frame(int dataSize){ std::uint32_t written; filerr = m_line_tx->write(&m_buffer0, 0, dataSize, written); - if (filerr) + if (filerr.value() != 0) { + osd_printf_verbose("M1COMM: tx connection lost\n"); + m_line_tx.reset(); if (m_linkalive == 0x01) { - osd_printf_verbose("M1COMM: tx connection lost\n"); m_linkalive = 0x02; m_linktimer = 0x00; - m_shared[0] = 0xff; - - m_line_rx.reset(); - m_line_tx.reset(); } } } diff --git a/src/mame/sega/m2comm.cpp b/src/mame/sega/m2comm.cpp index f590e0d3edbfd..a04f3d775cfbd 100644 --- a/src/mame/sega/m2comm.cpp +++ b/src/mame/sega/m2comm.cpp @@ -342,6 +342,8 @@ void m2comm_device::comm_tick() { if (m_linkenable == 0x01) { + std::error_condition filerr; + int frameStart = 0x2000; int frameSize = m_shared[0x13] << 8 | m_shared[0x12]; int frameOffset = frameStart | m_shared[0x15] << 8 | m_shared[0x14]; @@ -374,7 +376,12 @@ void m2comm_device::comm_tick() { osd_printf_verbose("M2COMM: listen on %s\n", m_localhost); uint64_t filesize; // unused - osd_file::open(m_localhost, OPEN_FLAG_CREATE, m_line_rx, filesize); + filerr = osd_file::open(m_localhost, OPEN_FLAG_CREATE, m_line_rx, filesize); + if (filerr.value() != 0) + { + osd_printf_verbose("M2COMM: rx connection failed\n"); + m_line_rx.reset(); + } } // check tx socket @@ -382,7 +389,12 @@ void m2comm_device::comm_tick() { osd_printf_verbose("M2COMM: connect to %s\n", m_remotehost); uint64_t filesize; // unused - osd_file::open(m_remotehost, 0, m_line_tx, filesize); + filerr = osd_file::open(m_remotehost, 0, m_line_tx, filesize); + if (filerr.value() != 0) + { + osd_printf_verbose("M2COMM: tx connection failed\n"); + m_line_tx.reset(); + } } // if both sockets are there check ring @@ -653,22 +665,38 @@ int m2comm_device::read_frame(int dataSize) togo -= recv; offset += recv; } - else if (!filerr && recv == 0) + switch (filerr.value()) { - togo = 0; + case 0x00: + case 0x8c: + // 00 - no error + // 8c - unknown error (read behind eof?) + break; + + default: + togo = 0; + break; } } } } - else if (!filerr && recv == 0) + switch (filerr.value()) { - if (m_linkalive == 0x01) - { + case 0x00: + case 0x8c: + // 00 - no error + // 8c - unknown error (read behind eof?) + break; + + default: osd_printf_verbose("M2COMM: rx connection lost\n"); - m_linkalive = 0x02; - m_linktimer = 0x00; m_line_rx.reset(); - } + if (m_linkalive == 0x01) + { + m_linkalive = 0x02; + m_linktimer = 0x00; + } + break; } return recv; } @@ -691,14 +719,14 @@ void m2comm_device::send_frame(int dataSize){ std::uint32_t written; filerr = m_line_tx->write(&m_buffer0, 0, dataSize, written); - if (filerr) + if (filerr.value() != 0) { + osd_printf_verbose("M2COMM: tx connection lost\n"); + m_line_tx.reset(); if (m_linkalive == 0x01) { - osd_printf_verbose("M2COMM: tx connection lost\n"); m_linkalive = 0x02; m_linktimer = 0x00; - m_line_tx.reset(); } } } diff --git a/src/mame/sega/s32comm.cpp b/src/mame/sega/s32comm.cpp index 667b6c50541e7..bd9a4c59a2cd8 100644 --- a/src/mame/sega/s32comm.cpp +++ b/src/mame/sega/s32comm.cpp @@ -287,22 +287,38 @@ int s32comm_device::read_frame(int dataSize) togo -= recv; offset += recv; } - else if (!filerr && recv == 0) + switch (filerr.value()) { - togo = 0; + case 0x00: + case 0x8c: + // 00 - no error + // 8c - unknown error (read behind eof?) + break; + + default: + togo = 0; + break; } } } } - else if (!filerr && recv == 0) + switch (filerr.value()) { - if (m_linkalive == 0x01) - { + case 0x00: + case 0x8c: + // 00 - no error + // 8c - unknown error (read behind eof?) + break; + + default: osd_printf_verbose("S32COMM: rx connection lost\n"); - m_linkalive = 0x02; - m_linktimer = 0x00; m_line_rx.reset(); - } + if (m_linkalive == 0x01) + { + m_linkalive = 0x02; + m_linktimer = 0x00; + } + break; } return recv; } @@ -326,14 +342,14 @@ void s32comm_device::send_frame(int dataSize){ std::uint32_t written; filerr = m_line_tx->write(&m_buffer0, 0, dataSize, written); - if (filerr) + if (filerr.value() != 0) { + osd_printf_verbose("S32COMM: tx connection lost\n"); + m_line_tx.reset(); if (m_linkalive == 0x01) { - osd_printf_verbose("S32COMM: tx connection lost\n"); m_linkalive = 0x02; m_linktimer = 0x00; - m_line_tx.reset(); } } } diff --git a/src/mame/sega/xbdcomm.cpp b/src/mame/sega/xbdcomm.cpp index 7284a296c9363..0d18083a518c0 100644 --- a/src/mame/sega/xbdcomm.cpp +++ b/src/mame/sega/xbdcomm.cpp @@ -308,6 +308,8 @@ void xbdcomm_device::comm_tick() { if (m_linkenable == 0x01) { + std::error_condition filerr; + uint8_t cabIdx = mpc_mem_r(0x4000); uint8_t cabCnt = mpc_mem_r(0x4001); @@ -366,7 +368,12 @@ void xbdcomm_device::comm_tick() { osd_printf_verbose("XBDCOMM: listen on %s\n", m_localhost); uint64_t filesize; // unused - osd_file::open(m_localhost, OPEN_FLAG_CREATE, m_line_rx, filesize); + filerr = osd_file::open(m_localhost, OPEN_FLAG_CREATE, m_line_rx, filesize); + if (filerr.value() != 0) + { + osd_printf_verbose("XBDCOMM: rx connection failed\n"); + m_line_rx.reset(); + } } // check tx socket @@ -374,7 +381,12 @@ void xbdcomm_device::comm_tick() { osd_printf_verbose("XBDCOMM: connect to %s\n", m_remotehost); uint64_t filesize; // unused - osd_file::open(m_remotehost, 0, m_line_tx, filesize); + filerr = osd_file::open(m_remotehost, 0, m_line_tx, filesize); + if (filerr.value() != 0) + { + osd_printf_verbose("XBDCOMM: tx connection failed\n"); + m_line_tx.reset(); + } } // if both sockets are there check ring @@ -559,26 +571,39 @@ int xbdcomm_device::read_frame(int dataSize) togo -= recv; offset += recv; } - else if (!filerr && recv == 0) + switch (filerr.value()) { - togo = 0; + case 0x00: + case 0x8c: + // 00 - no error + // 8c - unknown error (read behind eof?) + break; + + default: + togo = 0; + break; } } } } - else if (!filerr && recv == 0) + switch (filerr.value()) { - if (m_linkalive == 0x01) - { - osd_printf_verbose("XBDCOMM: rx connection lost\n"); - m_linkalive = 0x02; - m_linktimer = 0x00; - - m_z80_stat = 0xff; + case 0x00: + case 0x8c: + // 00 - no error + // 8c - unknown error (read behind eof?) + break; + default: + osd_printf_verbose("XBDCOMM: rx connection lost\n"); m_line_rx.reset(); - m_line_tx.reset(); - } + if (m_linkalive == 0x01) + { + m_linkalive = 0x02; + m_linktimer = 0x00; + m_z80_stat = 0xff; + } + break; } return recv; } @@ -601,18 +626,15 @@ void xbdcomm_device::send_frame(int dataSize){ std::uint32_t written; filerr = m_line_tx->write(&m_buffer0, 0, dataSize, written); - if (filerr) + if (filerr.value() != 0) { + osd_printf_verbose("XBDCOMM: tx connection lost\n"); + m_line_tx.reset(); if (m_linkalive == 0x01) { - osd_printf_verbose("XBDCOMM: tx connection lost\n"); m_linkalive = 0x02; m_linktimer = 0x00; - m_z80_stat = 0xff; - - m_line_rx.reset(); - m_line_tx.reset(); } } } diff --git a/src/mame/sega/ybdcomm.cpp b/src/mame/sega/ybdcomm.cpp index d6a1f1ab054c3..af6f7652cf892 100644 --- a/src/mame/sega/ybdcomm.cpp +++ b/src/mame/sega/ybdcomm.cpp @@ -396,6 +396,7 @@ void ybdcomm_device::comm_tick() { if (m_linkenable == 0x01) { + std::error_condition filerr; uint8_t cabIdx = mpc_mem_r(0x4000); int frameSize; @@ -425,7 +426,12 @@ void ybdcomm_device::comm_tick() { osd_printf_verbose("YBDCOMM: listen on %s\n", m_localhost); uint64_t filesize; // unused - osd_file::open(m_localhost, OPEN_FLAG_CREATE, m_line_rx, filesize); + filerr = osd_file::open(m_localhost, OPEN_FLAG_CREATE, m_line_rx, filesize); + if (filerr.value() != 0) + { + osd_printf_verbose("YBDCOMM: rx connection failed\n"); + m_line_rx.reset(); + } } // check tx socket @@ -433,7 +439,12 @@ void ybdcomm_device::comm_tick() { osd_printf_verbose("YBDCOMM: connect to %s\n", m_remotehost); uint64_t filesize; // unused - osd_file::open(m_remotehost, 0, m_line_tx, filesize); + filerr = osd_file::open(m_remotehost, 0, m_line_tx, filesize); + if (filerr.value() != 0) + { + osd_printf_verbose("YBDCOMM: tx connection failed\n"); + m_line_tx.reset(); + } } // if both sockets are there check ring @@ -624,26 +635,39 @@ int ybdcomm_device::read_frame(int dataSize) togo -= recv; offset += recv; } - else if (!filerr && recv == 0) + switch (filerr.value()) { - togo = 0; + case 0x00: + case 0x8c: + // 00 - no error + // 8c - unknown error (read behind eof?) + break; + + default: + togo = 0; + break; } } } } - else if (!filerr && recv == 0) + switch (filerr.value()) { - if (m_linkalive == 0x01) - { - osd_printf_verbose("YBDCOMM: rx connection lost\n"); - m_linkalive = 0x02; - m_linktimer = 0x00; - - m_z80_stat = 0xff; + case 0x00: + case 0x8c: + // 00 - no error + // 8c - unknown error (read behind eof?) + break; + default: + osd_printf_verbose("YBDCOMM: rx connection lost\n"); m_line_rx.reset(); - m_line_tx.reset(); - } + if (m_linkalive == 0x01) + { + m_linkalive = 0x02; + m_linktimer = 0x00; + m_z80_stat = 0xff; + } + break; } return recv; } @@ -667,18 +691,15 @@ void ybdcomm_device::send_frame(int dataSize) std::uint32_t written; filerr = m_line_tx->write(&m_buffer0, 0, dataSize, written); - if (filerr) + if (filerr.value() != 0) { + osd_printf_verbose("YBDCOMM: tx connection lost\n"); + m_line_tx.reset(); if (m_linkalive == 0x01) { - osd_printf_verbose("YBDCOMM: tx connection lost\n"); m_linkalive = 0x02; m_linktimer = 0x00; - m_z80_stat = 0xff; - - m_line_rx.reset(); - m_line_tx.reset(); } } }