chario: Move static variable to class.

This commit is contained in:
joevt 2024-01-27 15:21:58 -08:00 committed by dingusdev
parent 97727e0d1e
commit 1e587b0848
2 changed files with 21 additions and 7 deletions

View File

@ -206,8 +206,6 @@ void CharIoStdin::rcv_disable()
bool CharIoStdin::rcv_char_available()
{
static int consecutivechars = 0;
if (consecutivechars >= 15) {
consecutivechars++;
if (consecutivechars >= 400)
@ -340,8 +338,6 @@ void CharIoSocket::rcv_disable()
bool CharIoSocket::rcv_char_available()
{
static int consecutivechars = 0;
if (consecutivechars >= 15) {
consecutivechars++;
if (consecutivechars >= 800)
@ -406,7 +402,7 @@ bool CharIoSocket::rcv_char_available_now()
memset(&acceptfdaddr, 0, sizeof(acceptfdaddr));
socklen_t len = sizeof(acceptfdaddr);
acceptfd = accept(sockfd, (struct sockaddr *) &acceptfdaddr, &len);
if (acceptfd == -1){
if (acceptfd == -1) {
LOG_F(INFO, "socket accept err: %s", strerror(errno));
}
else {
@ -456,7 +452,13 @@ int CharIoSocket::xmit_char(uint8_t c)
LOG_F(INFO, "socket accept write err: %s", strerror(errno));
}
if (sent == 1) {
// LOG_F(INFO, "socket accept write '%c'", c);
/*
if (c < ' ') {
LOG_F(INFO, "socket accept write '\\x%02X'", c);
} else {
LOG_F(INFO, "socket accept write '%c'", c);
}
*/
}
else {
LOG_F(INFO, "socket accept write %d", sent);
@ -476,7 +478,17 @@ int CharIoSocket::rcv_char(uint8_t *c)
LOG_F(INFO, "socket accept read err: %s", strerror(errno));
}
else if (received == 1) {
// LOG_F(INFO, "socket accept read '%c'", c ? *c : 0);
/*
if (c) {
if (*c < ' ') {
LOG_F(INFO, "socket accept write '\\x%02X'", *c);
} else {
LOG_F(INFO, "socket accept read '%c'", *c);
}
} else {
LOG_F(INFO, "socket accept read %d", received);
}
*/
}
else {
LOG_F(INFO, "socket accept read %d", received);

View File

@ -81,6 +81,7 @@ public:
private:
static void mysig_handler(int signum);
bool stdio_inited;
int consecutivechars = 0;
};
/** Socket character I/O backend. */
@ -101,6 +102,7 @@ private:
int sockfd = -1;
int acceptfd = -1;
const char* path = 0;
int consecutivechars = 0;
};
#endif // CHAR_IO_H