위성과의 교신을 위해 지상국 시스템을 초기화 하는 과정에서 모뎀 장비에서 응답 신호가 수신되지 않아 전체 교신 프로세스가 실패하는 문제가 발생하였습니다.
12021/03/19 04:52:57 <RAU INITIALIZATION
22021/03/19 04:52:57 [CONTROL] Command Success - ACK 0
32021/03/19 04:52:57 <TMS INITIALIZATION
42021/03/19 04:52:57 [CONTROL] Command Success - ACK 0
52021/03/19 04:52:57 <IFR-1 INITIALIZATION
62021/03/19 04:52:58 [CONTROL] Command Success - ACK 0
72021/03/19 04:52:58 <TMU-A INITIALIZIATION
...
12021/03/19 04:47:03 <RAU INITIALIZATION
22021/03/19 04:47:23 <TMS INITIALIZATION
32021/03/19 04:47:43 <IFR-1 INITIALIZATION
42021/03/19 04:48:03 <TMU-A INITIALIZIATION
...
// Non-Blocking 소켓 생성
BOOL CreateNonBlockingSocket(SOCKET *pSocket)
{
*pSocket = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED);
if (*pSocket == INVALID_SOCKET)
{
return FALSE;
}
u_long iMode = 1; // 1 : non-blocking mode, 0 : blocking mode
int iResult = ioctlsocket(*pSocket, FIONBIO, &iMode);
if (iResult != NO_ERROR)
{
return FALSE;
}
return TRUE;
}
// Non-Blocking 소켓 연결
int ConnectWithTimeout(SOCKET socket, sockaddr_in addr, int timeoutSeconds)
{
if (connect(socket, (sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR) {
int error = WSAGetLastError();
if (error != WSAEWOULDBLOCK) {
return -error;
}
}
fd_set writefds;
FD_ZERO(&writefds);
FD_SET(socket, &writefds);
struct timeval tv;
memset(&tv, 0, sizeof(tv));
tv.tv_sec = timeoutSeconds;
tv.tv_usec = 0;
int result = select(0 /*ignored in windows*/, NULL, &writefds, NULL, &tv);
if (result == 0 || result == -1)
{
return SOCKET_ERROR;
}
return 0;
}
// Non-Blocking 수신
int ReceiveWithTimeout(SOCKET socket, char *buf, int len, int timeoutSeconds)
{
fd_set readfds;
FD_ZERO(&readfds);
FD_SET(socket, &readfds);
struct timeval tv;
tv.tv_sec = timeoutSeconds;
tv.tv_usec = 0;
int result = select(0 /*ignored in windows*/, &readfds, NULL, NULL, &tv);
if (result == 0 || result == SOCKET_ERROR)
{
return SOCKET_ERROR;
}
return recv(socket, buf, len, 0);
}
...