This commit is contained in:
QL 2018-11-29 13:16:29 -05:00
parent 19888ae2cd
commit e89d5ebe44
7 changed files with 3567 additions and 3368 deletions

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
/// @cond
///***************************************************************************
/// Last updated for version 6.3.7
/// Last updated on 2018-11-09
/// Last updated on 2018-11-29
///
/// Q u a n t u m L e a P s
/// ------------------------
@ -204,19 +204,41 @@ void QS::onReset(void) {
void QS::onFlush(void) {
uint16_t nBytes;
uint8_t const *data;
static struct timespec const c_10ms = { 0, 10000000L };
if (l_sock == INVALID_SOCKET) { // socket initialized?
if (l_sock == INVALID_SOCKET) { // socket NOT initialized?
fprintf(stderr, "<TARGET> ERROR invalid TCP socket\n");
return;
}
nBytes = QS_TX_CHUNK;
while ((data = getBlock(&nBytes)) != (uint8_t *)0) {
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
// the driver buffers the output, so it should accept all the bytes
if (nSent < (int)nBytes) {
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"errno=%d\n", errno);
for (;;) { // for-ever until break or return
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
if (nSent == SOCKET_ERROR) { /* sending failed? */
if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) {
// sleep for 10ms and then loop back
// to send() the SAME data again
//
nanosleep(&c_10ms, NULL);
}
else { // some other socket error...
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"errno=%d\n", errno);
return;
}
}
else if (nSent < (int)nBytes) { // sent fewer than requested?
nanosleep(&c_10ms, NULL); // sleep for 10ms */
// adjust the data and loop back to send() the rest
data += nSent;
nBytes -= (uint16_t)nSent;
}
else {
break;
}
}
// set nBytes for the next call to QS::getBlock()
nBytes = QS_TX_CHUNK;
}
}
@ -231,8 +253,6 @@ void QS::onTestLoop() {
(long)0, (long)(QS_IMEOUT_MS * 1000)
};
int nrec;
uint16_t nBytes;
uint8_t const *block;
FD_SET(l_sock, &readSet); // the socket
@ -267,14 +287,8 @@ void QS::onTestLoop() {
}
}
nBytes = QS_TX_SIZE;
//QF_CRIT_ENTRY(dummy);
block = getBlock(&nBytes);
//QF_CRIT_EXIT(dummy);
if (block != (uint8_t *)0) {
send(l_sock, (char const *)block, nBytes, 0);
}
// flush the QS TX buffer
onFlush();
}
// set inTestLoop to true in case calls to QS_onTestLoop() nest,
// which can happen through the calls to QS_TEST_PAUSE().

View File

@ -3,7 +3,7 @@
/// @cond
///***************************************************************************
/// Last updated for version 6.3.7
/// Last updated on 2018-11-09
/// Last updated on 2018-11-29
///
/// Q u a n t u m L e a P s
/// ------------------------
@ -70,6 +70,7 @@ namespace QP {
// local variables ...........................................................
static int l_sock = INVALID_SOCKET;
static struct timespec const c_10ms = { 0, 10000000L };
//............................................................................
bool QS::onStartup(void const *arg) {
@ -196,18 +197,39 @@ void QS::onFlush(void) {
uint16_t nBytes;
uint8_t const *data;
if (l_sock == INVALID_SOCKET) { // socket initialized?
if (l_sock == INVALID_SOCKET) { // socket NOT initialized?
fprintf(stderr, "<TARGET> ERROR invalid TCP socket\n");
return;
}
nBytes = QS_TX_CHUNK;
while ((data = getBlock(&nBytes)) != (uint8_t *)0) {
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
// the driver buffers the output, so it should accept all the bytes
if (nSent < (int)nBytes) {
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"errno=%d\n", errno);
for (;;) { // for-ever until break or return
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
if (nSent == SOCKET_ERROR) { /* sending failed? */
if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) {
// sleep for 10ms and then loop back
// to send() the SAME data again
//
nanosleep(&c_10ms, NULL);
}
else { // some other socket error...
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"errno=%d\n", errno);
return;
}
}
else if (nSent < (int)nBytes) { // sent fewer than requested?
nanosleep(&c_10ms, NULL); // sleep for 10ms */
// adjust the data and loop back to send() the rest
data += nSent;
nBytes -= (uint16_t)nSent;
}
else {
break;
}
}
// set nBytes for the next call to QS::getBlock()
nBytes = QS_TX_CHUNK;
}
}
@ -227,18 +249,39 @@ void QS_output(void) {
uint16_t nBytes;
uint8_t const *data;
if (l_sock == INVALID_SOCKET) { // socket initialized?
if (l_sock == INVALID_SOCKET) { // socket NOT initialized?
fprintf(stderr, "<TARGET> ERROR invalid TCP socket\n");
return;
}
nBytes = QS_TX_CHUNK;
if ((data = QS::getBlock(&nBytes)) != (uint8_t *)0) {
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
// the driver buffers the output, so it should accept all the bytes
if (nSent < (int)nBytes) {
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"errno=%d\n", errno);
for (;;) { // for-ever until break or return
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
if (nSent == SOCKET_ERROR) { /* sending failed? */
if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) {
// sleep for 10ms and then loop back
// to send() the SAME data again
//
nanosleep(&c_10ms, NULL);
}
else { // some other socket error...
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"errno=%d\n", errno);
return;
}
}
else if (nSent < (int)nBytes) { // sent fewer than requested?
nanosleep(&c_10ms, NULL); // sleep for 10ms */
// adjust the data and loop back to send() the rest
data += nSent;
nBytes -= (uint16_t)nSent;
}
else {
break;
}
}
// set nBytes for the next call to QS::getBlock()
nBytes = QS_TX_CHUNK;
}
}

View File

@ -3,7 +3,7 @@
/// @cond
///***************************************************************************
/// Last updated for version 6.3.7
/// Last updated on 2018-11-09
/// Last updated on 2018-11-29
///
/// Q u a n t u m L e a P s
/// ------------------------
@ -70,6 +70,7 @@ namespace QP {
// local variables ...........................................................
static int l_sock = INVALID_SOCKET;
static struct timespec const c_10ms = { 0, 10000000L };
//............................................................................
bool QS::onStartup(void const *arg) {
@ -196,18 +197,39 @@ void QS::onFlush(void) {
uint16_t nBytes;
uint8_t const *data;
if (l_sock == INVALID_SOCKET) { // socket initialized?
if (l_sock == INVALID_SOCKET) { // socket NOT initialized?
fprintf(stderr, "<TARGET> ERROR invalid TCP socket\n");
return;
}
nBytes = QS_TX_CHUNK;
while ((data = getBlock(&nBytes)) != (uint8_t *)0) {
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
// the driver buffers the output, so it should accept all the bytes
if (nSent < (int)nBytes) {
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"errno=%d\n", errno);
for (;;) { // for-ever until break or return
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
if (nSent == SOCKET_ERROR) { /* sending failed? */
if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) {
// sleep for 10ms and then loop back
// to send() the SAME data again
//
nanosleep(&c_10ms, NULL);
}
else { // some other socket error...
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"errno=%d\n", errno);
return;
}
}
else if (nSent < (int)nBytes) { // sent fewer than requested?
nanosleep(&c_10ms, NULL); // sleep for 10ms */
// adjust the data and loop back to send() the rest
data += nSent;
nBytes -= (uint16_t)nSent;
}
else {
break;
}
}
// set nBytes for the next call to QS::getBlock()
nBytes = QS_TX_CHUNK;
}
}
@ -227,18 +249,39 @@ void QS_output(void) {
uint16_t nBytes;
uint8_t const *data;
if (l_sock == INVALID_SOCKET) { // socket initialized?
if (l_sock == INVALID_SOCKET) { // socket NOT initialized?
fprintf(stderr, "<TARGET> ERROR invalid TCP socket\n");
return;
}
nBytes = QS_TX_CHUNK;
if ((data = QS::getBlock(&nBytes)) != (uint8_t *)0) {
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
// the driver buffers the output, so it should accept all the bytes
if (nSent < (int)nBytes) {
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"errno=%d\n", errno);
for (;;) { // for-ever until break or return
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
if (nSent == SOCKET_ERROR) { /* sending failed? */
if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) {
// sleep for 10ms and then loop back
// to send() the SAME data again
//
nanosleep(&c_10ms, NULL);
}
else { // some other socket error...
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"errno=%d\n", errno);
return;
}
}
else if (nSent < (int)nBytes) { // sent fewer than requested?
nanosleep(&c_10ms, NULL); // sleep for 10ms */
// adjust the data and loop back to send() the rest
data += nSent;
nBytes -= (uint16_t)nSent;
}
else {
break;
}
}
// set nBytes for the next call to QS::getBlock()
nBytes = QS_TX_CHUNK;
}
}

View File

@ -4,7 +4,7 @@
/// @cond
///***************************************************************************
/// Last updated for version 6.3.7
/// Last updated on 2018-11-14
/// Last updated on 2018-11-29
///
/// Q u a n t u m L e a P s
/// ------------------------
@ -203,18 +203,40 @@ void QS::onFlush(void) {
uint16_t nBytes;
uint8_t const *data;
if (l_sock == INVALID_SOCKET) { // socket initialized?
if (l_sock == INVALID_SOCKET) { // socket NOT initialized?
fprintf(stderr, "<TARGET> ERROR invalid TCP socket\n");
return;
}
nBytes = QS_TX_CHUNK;
while ((data = getBlock(&nBytes)) != static_cast<uint8_t *>(0)) {
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
// the driver buffers the output, so it should accept all the bytes
if (nSent < (int)nBytes) {
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"WASErr=%d\n", WSAGetLastError());
while ((data = getBlock(&nBytes)) != (uint8_t *)0) {
for (;;) { // for-ever until break or return
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
if (nSent == SOCKET_ERROR) { // sending failed?
int err = WSAGetLastError();
if (err == WSAEWOULDBLOCK) {
// sleep for 10ms and then loop back
// to send() the SAME data again
//
Sleep(10);
}
else { // some other socket error...
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"WASErr=%d\n", err);
return;
}
}
else if (nSent < (int)nBytes) { // sent fewer than requested?
Sleep(10); // sleep for 10ms
// adjust the data and loop back to send() the rest
data += nSent;
nBytes -= (uint16_t)nSent;
}
else {
break;
}
}
// set nBytes for the next call to QS::getBlock()
nBytes = QS_TX_CHUNK;
}
}
@ -229,8 +251,6 @@ void QS::onTestLoop() {
(long)0, (long)(QS_IMEOUT_MS * 1000)
};
int status;
uint16_t nBytes;
uint8_t const *block;
int ch;
FD_SET(l_sock, &readSet);
@ -262,14 +282,9 @@ void QS::onTestLoop() {
}
}
nBytes = QS_TX_SIZE;
//QF_CRIT_ENTRY(dummy);
block = getBlock(&nBytes);
//QF_CRIT_EXIT(dummy);
// flush the QS TX buffer
onFlush();
if (block != (uint8_t *)0) {
send(l_sock, (char const *)block, nBytes, 0);
}
ch = 0;
while (_kbhit()) { // any key pressed?
ch = _getch();

View File

@ -4,7 +4,7 @@
/// @cond
///***************************************************************************
/// Last updated for version 6.3.7
/// Last updated on 2018-11-09
/// Last updated on 2018-11-29
///
/// Q u a n t u m L e a P s
/// ------------------------
@ -189,18 +189,40 @@ void QS::onFlush(void) {
uint16_t nBytes;
uint8_t const *data;
if (l_sock == INVALID_SOCKET) { // socket initialized?
if (l_sock == INVALID_SOCKET) { // socket NOT initialized?
fprintf(stderr, "<TARGET> ERROR invalid TCP socket\n");
return;
}
nBytes = QS_TX_CHUNK;
while ((data = getBlock(&nBytes)) != (uint8_t *)0) {
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
// the driver buffers the output, so it should accept all the bytes
if (nSent < (int)nBytes) {
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"WASErr=%d\n", WSAGetLastError());
for (;;) { // for-ever until break or return
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
if (nSent == SOCKET_ERROR) { // sending failed?
int err = WSAGetLastError();
if (err == WSAEWOULDBLOCK) {
// sleep for 10ms and then loop back
// to send() the SAME data again
//
Sleep(10);
}
else { // some other socket error...
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"WASErr=%d\n", err);
return;
}
}
else if (nSent < (int)nBytes) { // sent fewer than requested?
Sleep(10); // sleep for 10ms
// adjust the data and loop back to send() the rest
data += nSent;
nBytes -= (uint16_t)nSent;
}
else {
break;
}
}
// set nBytes for the next call to QS::getBlock()
nBytes = QS_TX_CHUNK;
}
}
@ -216,19 +238,39 @@ void QS_output(void) {
uint16_t nBytes;
uint8_t const *data;
if (l_sock == INVALID_SOCKET) { // socket initialized?
if (l_sock == INVALID_SOCKET) { // socket NOT initialized?
fprintf(stderr, "<TARGET> ERROR invalid TCP socket\n");
return;
}
nBytes = QS_TX_CHUNK;
if ((data = QS::getBlock(&nBytes)) != (uint8_t *)0) {
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
// the driver buffers the output, so it should accept all the bytes
if (nSent < (int)nBytes) {
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"WASErr=%d\n", WSAGetLastError());
for (;;) { // for-ever until break or return
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
if (nSent == SOCKET_ERROR) { // sending failed?
int err = WSAGetLastError();
if (err == WSAEWOULDBLOCK) {
// sleep for 10ms and then loop back
// to send() the SAME data again
//
Sleep(10);
}
else { // some other socket error...
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"WASErr=%d\n", err);
return;
}
}
else if (nSent < (int)nBytes) { // sent fewer than requested?
Sleep(10); // sleep for 10ms
// adjust the data and loop back to send() the rest
data += nSent;
nBytes -= (uint16_t)nSent;
}
else {
break;
}
}
nBytes = QS_TX_CHUNK;
}
}
//............................................................................

View File

@ -4,7 +4,7 @@
/// @cond
///***************************************************************************
/// Last updated for version 6.3.7
/// Last updated on 2018-11-09
/// Last updated on 2018-11-29
///
/// Q u a n t u m L e a P s
/// ------------------------
@ -189,18 +189,40 @@ void QS::onFlush(void) {
uint16_t nBytes;
uint8_t const *data;
if (l_sock == INVALID_SOCKET) { // socket initialized?
if (l_sock == INVALID_SOCKET) { // socket NOT initialized?
fprintf(stderr, "<TARGET> ERROR invalid TCP socket\n");
return;
}
nBytes = QS_TX_CHUNK;
while ((data = getBlock(&nBytes)) != (uint8_t *)0) {
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
// the driver buffers the output, so it should accept all the bytes
if (nSent < (int)nBytes) {
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"WASErr=%d\n", WSAGetLastError());
for (;;) { // for-ever until break or return
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
if (nSent == SOCKET_ERROR) { // sending failed?
int err = WSAGetLastError();
if (err == WSAEWOULDBLOCK) {
// sleep for 10ms and then loop back
// to send() the SAME data again
//
Sleep(10);
}
else { // some other socket error...
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"WASErr=%d\n", err);
return;
}
}
else if (nSent < (int)nBytes) { // sent fewer than requested?
Sleep(10); // sleep for 10ms
// adjust the data and loop back to send() the rest
data += nSent;
nBytes -= (uint16_t)nSent;
}
else {
break;
}
}
// set nBytes for the next call to QS::getBlock()
nBytes = QS_TX_CHUNK;
}
}
@ -216,19 +238,39 @@ void QS_output(void) {
uint16_t nBytes;
uint8_t const *data;
if (l_sock == INVALID_SOCKET) { // socket initialized?
if (l_sock == INVALID_SOCKET) { // socket NOT initialized?
fprintf(stderr, "<TARGET> ERROR invalid TCP socket\n");
return;
}
nBytes = QS_TX_CHUNK;
if ((data = QS::getBlock(&nBytes)) != (uint8_t *)0) {
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
// the driver buffers the output, so it should accept all the bytes
if (nSent < (int)nBytes) {
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"WASErr=%d\n", WSAGetLastError());
for (;;) { // for-ever until break or return
int nSent = send(l_sock, (char const *)data, (int)nBytes, 0);
if (nSent == SOCKET_ERROR) { // sending failed?
int err = WSAGetLastError();
if (err == WSAEWOULDBLOCK) {
// sleep for 10ms and then loop back
// to send() the SAME data again
//
Sleep(10);
}
else { // some other socket error...
fprintf(stderr, "<TARGET> ERROR sending data over TCP,"
"WASErr=%d\n", err);
return;
}
}
else if (nSent < (int)nBytes) { // sent fewer than requested?
Sleep(10); // sleep for 10ms
// adjust the data and loop back to send() the rest
data += nSent;
nBytes -= (uint16_t)nSent;
}
else {
break;
}
}
nBytes = QS_TX_CHUNK;
}
}
//............................................................................