working on normCast Win32 support

pull/9/head
bebopagogo 2019-12-27 13:53:32 -05:00
parent 1f0f97f5b5
commit 3eb8b83a33
2 changed files with 27 additions and 15 deletions

View File

@ -273,10 +273,7 @@ bool NormCaster::Start(bool sender, bool receiver)
NormSetBackoffFactor(norm_session, 0); NormSetBackoffFactor(norm_session, 0);
// Pick a random instance id for now // Pick a random instance id for now
struct timeval currentTime; NormSessionId instanceId = NormGetRandomSessionId();
gettimeofday(&currentTime, NULL);
srand(currentTime.tv_usec); // seed random number generator
NormSessionId instanceId = (NormSessionId)rand();
if (!NormStartSender(norm_session, instanceId, bufferSize, segmentSize, blockSize, numParity)) if (!NormStartSender(norm_session, instanceId, bufferSize, segmentSize, blockSize, numParity))
{ {
fprintf(stderr, "normCast error: unable to start NORM sender\n"); fprintf(stderr, "normCast error: unable to start NORM sender\n");
@ -618,6 +615,8 @@ int main(int argc, char* argv[])
double txloss = 0.0; double txloss = 0.0;
bool loopback = false; bool loopback = false;
TRACE("parsing command-line ...\n");
NormCaster normCast; NormCaster normCast;
// Parse command-line // Parse command-line
@ -862,19 +861,29 @@ int main(int argc, char* argv[])
return -1; return -1;
} }
TRACE("calling NormCreateInstance() ...\n");
// TBD - should provide more error checking of calls // TBD - should provide more error checking of calls
NormInstanceHandle normInstance = NormCreateInstance(); NormInstanceHandle normInstance = NormCreateInstance();
TRACE("calling NormSetDebugLevel() ...\n");
NormSetDebugLevel(debugLevel); NormSetDebugLevel(debugLevel);
if (NULL != debugLog) if (NULL != debugLog)
{
TRACE("calling NormOpenDebugLog() ...\n");
NormOpenDebugLog(normInstance, debugLog); NormOpenDebugLog(normInstance, debugLog);
}
TRACE("calling NormSetCacheDirectory() (recv:%d) ...\n", recv);
// TBD - enhance NORM to support per-session or perhaps per-sender rx cache directories? // TBD - enhance NORM to support per-session or perhaps per-sender rx cache directories?
if (recv) if (recv)
NormSetCacheDirectory(normInstance, normCast.GetRxCacheDirectory()); NormSetCacheDirectory(normInstance, normCast.GetRxCacheDirectory());
TRACE("calling SetLoopback() ...\n");
normCast.SetLoopback(loopback); normCast.SetLoopback(loopback);
TRACE("calling SetFlushing() ...\n");
normCast.SetFlushing(flushing); normCast.SetFlushing(flushing);
TRACE("calling OpenNormSession() ...\n");
if (!normCast.OpenNormSession(normInstance, sessionAddr, sessionPort, (NormNodeId)nodeId)) if (!normCast.OpenNormSession(normInstance, sessionAddr, sessionPort, (NormNodeId)nodeId))
{ {
fprintf(stderr, "normCast error: unable to open NORM session\n"); fprintf(stderr, "normCast error: unable to open NORM session\n");
@ -896,17 +905,18 @@ int main(int argc, char* argv[])
if (trace) normCast.SetNormMessageTrace(true); if (trace) normCast.SetNormMessageTrace(true);
TRACE("calling Start() ...\n");
// TBD - set NORM session parameters // TBD - set NORM session parameters
normCast.Start(send, recv); normCast.Start(send, recv);
TRACE("calling SendFiles() ...\n");
if (normCast.TxFilePending()) normCast.SendFiles(); if (normCast.TxFilePending()) normCast.SendFiles();
#ifdef WIN32 #ifdef WIN32
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); //Win32InputHandler inputHandler;
Win32InputHandler inputHandler; //inputHandler.Open();
inputHandler.Open();
HANDLE handleArray[2]; HANDLE handleArray[2];
handleArray[0] = NormGetDescriptor(instance); handleArray[0] = NormGetDescriptor(normInstance);
bool inputNeeded = false; // set this to 'true', and uncomment next line for STDIN input notification bool inputNeeded = false; // set this to 'true', and uncomment next line for STDIN input notification
//handleArray[1] = inputHandler.GetEventHandle(); //handleArray[1] = inputHandler.GetEventHandle();
#else #else
@ -916,6 +926,7 @@ int main(int argc, char* argv[])
FD_ZERO(&fdsetInput); FD_ZERO(&fdsetInput);
#endif // if/else WIN32/UNIX #endif // if/else WIN32/UNIX
TRACE("entering main loop ...\n");
while (normCast.IsRunning()) while (normCast.IsRunning())
{ {
// TBD - could add "stdin" as a descriptor to monitor // TBD - could add "stdin" as a descriptor to monitor
@ -924,6 +935,7 @@ int main(int argc, char* argv[])
bool normEventPending = false; bool normEventPending = false;
bool inputEventPending = false; bool inputEventPending = false;
#ifdef WIN32 #ifdef WIN32
TRACE("calling MsgWaitForMultipleObjectsEx() ...\n");
DWORD handleCount = inputNeeded ? 2 : 1; DWORD handleCount = inputNeeded ? 2 : 1;
DWORD waitStatus = DWORD waitStatus =
MsgWaitForMultipleObjectsEx(handleCount, // number of handles in array MsgWaitForMultipleObjectsEx(handleCount, // number of handles in array

View File

@ -338,9 +338,9 @@ bool NormPresetObjectInfo(NormSessionHandle sessionHandle, // FEC O
UINT16 segmentSize, UINT16 segmentSize,
UINT16 numData, UINT16 numData,
UINT16 numParity); UINT16 numParity);
// non-public on purpose
NORM_API_LINKAGE //NORM_API_LINKAGE
void NormSetId(NormSessionHandle sessionHandle, NormNodeId normId); //void NormSetId(NormSessionHandle sessionHandle, NormNodeId normId);
// This does not affect the rx_socket binding if already bound (sender or receiver already started) // This does not affect the rx_socket binding if already bound (sender or receiver already started)
// (i.e., just affects where NORM packets are sent) // (i.e., just affects where NORM packets are sent)