Remove socket IO mode (nonblock unnecessary with pre-checked recv buffer)
This commit is contained in:
@@ -466,7 +466,6 @@ int8_t init_buffers(std::span<const uint8_t> txsize, std::span<const uint8_t> rx
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t sock_io_mode_bits = 0;
|
||||
uint16_t sock_is_sending = 0;
|
||||
uint16_t sock_remained_size[sock_count] = {0,};
|
||||
uint8_t sock_pack_info[sock_count] = {0,};
|
||||
@@ -481,7 +480,6 @@ std::expected<void, sock_error> close(socket_id sid) {
|
||||
set_sn_cr(sn, SN_CR_CLOSE);
|
||||
while (get_sn_cr(sn));
|
||||
set_sn_ir(sn, 0xFF);
|
||||
sock_io_mode_bits &= ~(1 << sn);
|
||||
sock_is_sending &= ~(1 << sn);
|
||||
sock_remained_size[sn] = 0;
|
||||
sock_pack_info[sn] = PACK_NONE;
|
||||
@@ -517,7 +515,6 @@ std::expected<socket_id, sock_error> open_socket(socket_id sid, protocol proto,
|
||||
set_sn_mr2(sn, fl & 0x03);
|
||||
set_sn_cr(sn, SN_CR_OPEN);
|
||||
while (get_sn_cr(sn));
|
||||
sock_io_mode_bits &= ~(1 << sn);
|
||||
sock_is_sending &= ~(1 << sn);
|
||||
sock_remained_size[sn] = 0;
|
||||
sock_pack_info[sn] = PACK_COMPLETED;
|
||||
@@ -538,7 +535,6 @@ std::expected<uint16_t, sock_error> send(socket_id sid, std::span<const uint8_t>
|
||||
while (1) {
|
||||
freesize = get_sn_tx_fsr(sn);
|
||||
if (get_sn_sr(sn) == SOCK_CLOSED) FAIL(sock_closed);
|
||||
if ((sock_io_mode_bits & (1 << sn)) && (len > freesize)) FAIL(busy);
|
||||
if (len <= freesize) break;
|
||||
};
|
||||
send_data(sn, const_cast<uint8_t*>(buf.data()), len);
|
||||
@@ -574,7 +570,6 @@ std::expected<uint16_t, sock_error> recv(socket_id sid, std::span<uint8_t> buf)
|
||||
sock_pack_info[sn] = PACK_NONE;
|
||||
break;
|
||||
}
|
||||
if (sock_io_mode_bits & (1 << sn)) FAIL(busy);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -636,14 +631,6 @@ bool check() {
|
||||
return get_cidr() == 0x6300;
|
||||
}
|
||||
|
||||
std::expected<void, sock_error> set_socket_io_mode(socket_id sid, sock_io_mode mode) {
|
||||
uint8_t sn = static_cast<uint8_t>(sid);
|
||||
if (sn >= sock_count) FAIL(sock_num);
|
||||
if (mode == sock_io_mode::nonblock) sock_io_mode_bits |= (1 << sn);
|
||||
else if (mode == sock_io_mode::block) sock_io_mode_bits &= ~(1 << sn);
|
||||
else FAIL(arg);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
uint16_t get_socket_recv_buf(socket_id sid) {
|
||||
|
||||
Reference in New Issue
Block a user