I've installed (and have been using it for a while now) mongocxx driver via vcpkg and everything installed correctly and runs perfectly in Debug version (I'm using Visual Studio 2017 and my application is a Windows Form c++ (CLR) application). In my application, I get a connection pool and acquire a client everytime I upload some data on the server. Typical interval of my automatic data upload is 10 minutes.
My settings are
// Create pool (once)
mongocxx::uri uri_remote{ "mongodb://user:pwd#remote-host:PORT/database-name?minPoolSize=2&maxPoolSize=5" };
mongocxx::pool pool_remote{ uri_remote };
// The code below runs as a scheduled process after every 10 minutes
auto client_remote = pool_remote.acquire();
// The client is returned to the pool when it goes out of scope.
auto collection_remote = (*client_remote)["database-name"]["collection-1-name"];
auto collection_st_remote = (*client_remote)["database-name"]["collection-2-name"];
bsoncxx::document::value doc1= document
<< std::string(keys[0]) << entries[0] // A short string (device identifier)
<< std::string(keys[1]) << entries[1] // A short string location
<< std::string(keys[2]) << bsoncxx::types::b_date(std::chrono::system_clock::now()) // Current insert time
<< std::string(keys[3]) << entries[2] // String: updated entry name
<< std::string(keys[4]) << entries[3] // String: Updated entry description
<< std::string(keys[5]) << <float number>
<< std::string(keys[6]) << <integer>
<< finalize;
// Below are the statuses I'm recording. A binary array (length = 7)
bsoncxx::document::value doc2= document
<< std::string(status_keys[0]) << statuses[0]
<< std::string(status_keys[1]) << statuses[1]
<< std::string(status_keys[2]) << statuses[2]
<< std::string(status_keys[3]) << statuses[3]
<< std::string(status_keys[4]) << bsoncxx::types::b_date(std::chrono::system_clock::now())
<< std::string(status_keys[5]) << statuses[4] // Device identifier
<< std::string(status_keys[6]) << statuses[5]
<< finalize;
// And finally insert
try {
// Insert remote. lines of code for doc1 and doc2 are skipped
collection_remote.insert_one(doc1.view());
collection_st_remote.insert_one(doc2.view());
// I'm skipping the rest of the code section here (just a catch statement after this). . .
The problem, the database documents get uploaded every 10 minutes without a problem in Debug version, but with the Release version (when I loaded the Release version of my application and started using that), the mongo insert doesn't work every time 10 minutes. It just misses/skips some entries (mostly one after a successful attempt according to what I observed).
With the release version loaded in a remote computer I'm unable to do any debugging even though I ran debug version which works perfectly with shorter intervals too (like 1 minute each).
Related
I am trying to understand how device unbinding works?
I have a module with which two devices are attached.
Dev1
Dev2
Devices dev1 and dev2 are created in probe function.
Each device(dev1/dev2) creates one more char device under it.
Basically the module has probe and remove
Probe creates device which registers one more char device (with char device own file operations)
remove functionality is for the module(dev1/dev2)
Dev1 & Dev 2, registered char device file operations includes ioctl.
Issue:
Unbinding of device dev1 or dev2 does not wait for char device file operations to finish.
So every time unbind of device happens while ioctl is in progress, system gives oops.
Tried to open and release in fops for the device but didnt help.
Include debug Print in char device fops, release,
the debug print is seen after the device is unbinded.(verified with debug print in remove of dev1/dev2)
Current debug print seq:
~~~ Device removed ~~~ (from module remove)
~~~ Char device released ~~~ (from char device)
Expectation:
Unbinding of device(dev1/dev2) should wait for the char device fops to complete.
Expected debug print seq:
~~~ Char device released ~~~ (from char device)
~~~ Device removed ~~~ (from module remove)
I have a Qt5.12.4 MinGw64 app where I want to catch a USB event. In Windows 10 the MS driver for STM/USB emits error messages and I can use that as a trigger. Inelegant but it works, until I try to run it in a Win7-8.1 app where the driver is a third party STM driver with a VCP wrapper. I am thinking I need to adopt libusb to try and catch the ports change of state, but I am at a loss as how to proceed. I can see the port info in Device Manager, I just dont know how to get to it. Some of the questions going through my head....
1) Can I just make an OS call to read the port info? (if so, how?)
2) Can libusb and QSerialport co-exist on the same port?
3) What calls to LibUSB1.0 do I make to query the port status?
4) Is there a Windows cli utility like lsusb (wmic??) where I could scrape the data?
5) Which solution is likely to be the best cross platform solution?
I am using this trigger to start dfuse as a process that does a firmware update automatically on my STM board.
I have looked over the libusb1.0 docs but I do not understand just how I can use it. If that is correct solution, an example of how to query the Com port data and state would be most appreciated.
I tried using qDebug() to print out all of the serialportInfo data, while in serial or DFU state, but there is nothing there that is useful that I can use as a trigger.
USB serial mode = Serial port info is: ("COM3", "USB Serial Device", "Microsoft", "00000000001A", "\\.\COM3", "483", "5740", "1", " no data", "1")
USB DFU mode = Serial port info is: ("COM3", "N/A", "N/A", "N/A", "\\.\COM3", "N/A", "N/A", "no data", " no data", "no data")
I need some direction as to how to grab this port info so I dont really have any code that matters, but I am including an excerpt of my working process function.
This code works just fine to actually perform the firmware load. I just need a way to actually trigger it from a USB port change of state
void updateDevice_Dialog::update_firmware(QString fileName)
{
qDebug() << "Updating firmware: " << fileName ;
QDir dir;
ui->progress_label->setText("Preparing to update Firmware .....");
if(dir.setCurrent(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)+"/firmware"))
{
QSettings settings;
QString comPort = settings.value("USBPort").toString();
ui->progress_label->setText("Setting port to: "+comPort+" and starting download .....");
ui->avr_progressBar->setValue(0);
ui->avr_progressBar->setRange(0,100);
ui->avr_progressBar->setHidden(false);
progress_steps = 0; //reset avrProcess line output counter;
qDebug() << "Starting process for stm-dfu on serial port: " << comPort;
connect(avr_Process,SIGNAL(error(QProcess::ProcessError)),this,SLOT(process_error(QProcess::ProcessError)));
connect(avr_Process,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(process_finished(int,QProcess::ExitStatus)));
connect(avr_Process,SIGNAL(readyReadStandardOutput()),this,SLOT(process_readLine()));
connect(avr_Process,SIGNAL(errorOccurred(QProcess::ProcessError)),avr_Process,SLOT(kill()));
connect(avr_Process,SIGNAL(error(QProcess::ProcessError)),ui->avr_progressBar,SLOT(close()));
QString dfu_command = "\""+QCoreApplication::applicationDirPath()+"/Tools/\"dfusecommand -c -d --v --fn "
"\""+QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)+"/firmware/\""+fileName;
qDebug().noquote() << "dfu command string is: "<< dfu_command << " Current dir is: " << dir.currentPath();
avr_Process->start(dfu_command);
avr_Process->waitForFinished(20000);
}
}
From the perspective of the host system, rebooting the microcontroller into DFU will look like the original device was disconnected, and a completely different device was plugged in shortly afterwards.
If you need to watch for this, set up a libusb hotplug callback so that you'll be notified when the DFU device is attached.
I apologize if I'm a bit low on details here, but the main issue is actually trying to find the problem with my code. I'm updating an older extension of my own that was based on the Language Server example (https://code.visualstudio.com/docs/extensions/example-language-server). I've run into an issue where when I run the client part of my code using F5, and the debug window fires, I get:
The CSSLint Language Client server crashed 5 times in the last 3 minutes. The server will not be restarted.
Ok... so... here's the thing. The problems view in my extension client code shows nothing. DevTools for that Code window shows nothing.
The problems view for my server code shows nothing. DevTools, ditto.
For the Extension Developer Host instance, DevTools does show this:
messageService.ts:126 The CSSLint Language Client server crashed 5 times in the last 3 minutes. The server will not be restarted.e.doShow # messageService.ts:126
But I can't dig into the details to find a bug. So the question is - assuming that my server code is failing, where exactly would the errors be available?
Here is what I usually do to track server crashes down (I assume your server is written in JavaScript / TypeScript).
Use the following server options:
let serverModule = "path to your server"
let debugOptions = { execArgv: ["--nolazy", "--debug=6009"] };
let serverOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions}
};
Key here is to use the TransportKind.ipc. Errors that happen in the server and printed to stdio will then show in the output channel associated to your server (the name of the output channel is the name passed to the LanguageClient)
If you want to debug the server startup / initialize sequence you can change the debugOptions to:
let debugOptions = { execArgv: ["--nolazy", "--debug-brk=6009"] };
If the extension is started in debug mode (e.g. for example launched from VS Code using F5) then the LanguageClient automatically starts the server in debug mode. If the extension is started normally (for example as a real extension in VS Code) then the server is started normally as well.
To make this all work you need a latest version of the LSP node npm module both for server can client (e.g. 2.6.x)
hello I am newby to irda sockets. I have a macbook pro that has a built-in Apple IR reciver. I am using visual studio 2013,
#include <af_irda.h>
#include <winsock2.h>
#incude <iostream>
using namespace std;
#pragma comment(lib,"ws2_32.lib")
int main()
{
WORD wVersion = MAKEWORD(2,2);
WSADATA wSaData;
if(WSAStartup(wVersion), &wSaData))
{
cout << "Failed to initialize winsock library!\n";
return 1;
}
int irSock = socket(AF_IRDA, SOCK_STREAM, 0);
if(irSock == SOCKET_ERROR)
{
cout << "Socket creation failed! error code: " << WSAGetLastError() << endl;
}
//the socket creation failed with 10047
cout << endl << endl << endl;
system("pause");
return 0;
}
does this mean that my laptop doesn't have irda adapter?? if so what is IR receiver then?? can't we use IR receiver to write irda socket applications???
*** please anyhelp is highly appreciated
1- socket creation failed and WSAGetLastError() returns 10047 when the address family is not supported. (ie: the error doesn't belong to hardware but to platform)
on windows7, 8, 10 (almost all new windows OSs exclude irDA support) we get this error while on windows xp, linux fedora the socket creation succeeds BUT this doesn't mean that your laptop/pc is necessarily provided with irDA adapter.
2- IR receiver is not an irDA adapter:
An IR receiver is just a dumb receiver that reads IR commands (that was a tough one!). IRDA is a complex bidirectional protocol involving reliable communication with acknowledgments typically used to transfer files or emulate a serial interface between hand held devices and a laptop or PC. Or, as Wannabe said, you want an IR receiver since IRDA doesn't know how to listen to remote commands.
I'm attempting to start mongos and fail fast if the config server is unavailable. Right now, with an unavailable config server, I'm seeing:
Tue Feb 12 11:09:13 [mongosMain] can't resolve DNS for [compute-1-3] sleeping and trying 10 more times
How do I configure the 10?
The 10 retries is hard coded, it is not configurable. You can see it here:
https://github.com/mongodb/mongo/blob/master/src/mongo/s/config.cpp#L742
Just in case line numbers change, here's the relevant counter/loop:
for ( int x=10; x>0; x-- ) {
if ( ! hostbyname( host.c_str() ).empty() ) {
ok = true;
break;
}
log() << "can't resolve DNS for [" << host << "] sleeping and trying " << x << " more times" << endl;
sleepsecs( 10 );
Therefore you could, in theory, alter the code and re-build yourself, but then you would have to maintain that for new versions. I would recommend instead that you keep the config server available instead, or at least have it up within ~100 seconds of the mongos starting.