Home > Software engineering >  MFC to save data in SD card, in the process of storing data for the card, how to deal with
MFC to save data in SD card, in the process of storing data for the card, how to deal with

Time:09-23

I use industrial tablet computers, through a serial port receives the data, the data will be processed after saved to the SD card in a TXT file, in the process of software running if artificial pull out SD card, the software will crash, now want to get a storage solution, thank you very much

CodePudding user response:

When writing the return of the interface have a judge? Can be judged in terms of writing data return to the interface, if write how many times failure, return an error,
But don't know what you specific use interface, did not dare to assert that

CodePudding user response:


Crash is your exception handling does not reach the designated position,
Considering all kinds of possible exception,

CodePudding user response:

You don't put the process of writing the data in the main thread, and every time check exception to write before writing, writing in the process of doing a timer timeout handling

CodePudding user response:

I was written using MFC CFile category, write data also can judge to success or failure? What happened when the timer timeout handling, can detailed say? please

CodePudding user response:

I also useful anomaly judgment kind thing, but the result is the same, don't know what to do now, will judge SD card state is, the file is opened, but writing in the process of SD card are pulled out, the result can't write in it? If this is possible?

CodePudding user response:

CFile, speaking, reading and writing using the try catch catch CFileException

CodePudding user response:

Open a write threads and abnormal judgment

CodePudding user response:

Don't try to the end of the elegant (because it is impossible)
And want to be in bad can't lousy can stall on reforming land!

CodePudding user response:

Use CFile add try catch catch CFileException, tried, won't work

CodePudding user response:

Can write elsewhere, the SD card, then finish at a time, do it again copy file, determine the path of the SD card before copy is effective, if invalid, ineffective treatment, effective, direct copy,

CodePudding user response:

Do a monitor USB monitor thread when there is testing whether you are using USB disconnect the device and modify logo on a write code that judgment, then suggest exit,

CodePudding user response:

Try {}
Cache {}
Catches no exception

CodePudding user response:

When the system equipment change, they emit WM_DEVICECHANGE message, if the device is removed, the message parameter as DBT_DEVICEREMOVEPENDING, again the moment, can carry out your "helpless" processing

CodePudding user response:

refer to the eighth floor zhao4zhong1 response:
don't attempt to the end of the elegant (because it is impossible)
And want to be in bad can't lousy can stall on reforming land!

Industrial control class data, better preserve, local leave 1, network, external devices to catch exceptions, VS, OFFICE have not recovering after crashing? What to do,,,
  • Related