Creating a log file in embedded VC++ using Win32 API - winapi

Can any one help me on how to create a log file in embedded VC++ using the Win32 API?
Right now, I'm trying to create multiple file on WinCE PC. For this I need to provide a log file whether a file is created or not. I am able to create a message on console but I need to store that message in a text file instead of displaying for each and every file.

Possibly answered in High performance logging library for embedded applications ?
Ok, I read your question again - in case you cannot pull in a library, you may want to read this one instead: how do I write a logger class with cout style interface (logger << "Error: " << val << endl;)

Related

How to add custom information model XML.file to server and run It?

I'm currently working on open62541. I created one object XML file. now I want to add the file to server and try to run server. when server runs the XML file contain objects should be show on opcua-client application.
In 3 steps:
you need a nodeset.xml file
use cmake command to generate source code from it
call a function in your executable
1
I do not know what kind of "XML" file you have.
I would assume you have a valid nodeset.xml file.
if you do not know how to do it,you can try read this: https://opcua.rocks/custom-information-models/
personally i suggest to use a GUI tool for that (e.g. free opc ua modeler)
2
Then you should use following custom CMake commands provides by open62541
# Generate types and namespace for DI
ua_generate_nodeset_and_datatypes(
NAME "di" # the name you want
FILE_CSV "${UA_NODESET_DIR}/DI/OpcUaDiModel.csv"
FILE_BSD "${UA_NODESET_DIR}/DI/Opc.Ua.Di.Types.bsd"
NAMESPACE_MAP "2:http://opcfoundation.org/UA/DI/"
FILE_NS "${UA_NODESET_DIR}/DI/Opc.Ua.Di.NodeSet2.xml"
)
after build, you would find bunches of ua_xxxx_generated.c and ua_xxxx——generated.h file under build/src_generated folder.
Then in your programm code just include these headers and call
3
namespace_xxx_nodeset_generated(server)
please refer to https://github.com/open62541/open62541/tree/master/examples/nodeset
and
http://www.open62541.org/doc/master/nodeset_compiler.html
There are rich example and codes for that

RDOMail.SaveAs sometimes doesn't work over a UNC

I have a C# Outlook add-in that is using the Redemption library.
This add-in, among other things, copy the selected mail to a share somewhere on the network.
It usually works pretty well but sometimes, the .msg file on the share seems to be corrupted. It cannot be read by the service that tries to process it. Double clicking on it shows this message: "Cannot read the item".
Sometimes, I can see an error message:
SaveEmail - System.Runtime.InteropServices.COMException (0x8007000):
Error in StgCreateDocFile: 0x8007000 at
Redemption.IRDOMail.SaveAs(String Path, Object Type) at
XYZNameSpace.Email.SaveEmail(...)
Here the code that save the mail to the share:
// Save the mail in a temp local file first
mailItem.SaveAs(temppath, Outlook.OlSaveAsType.olMSG);
(... some processing ...)
// Reload the mail
RDOMail rm = rdoSession.GetMessageFromMsgFile(temppath);
// Save it again on a share
rm.SaveAs(filePathName, Outlook.OlSaveAsType.olMSG);
Note 1 : I don't know why the mail is first saved locally!
Note 2 : It is using an older version of Redemption (2015).
Note 3 : The size of the message doesn't seem important. However, they are
usually between 2 and 15 MB.
Many thanks in advance.
IStorage API does not really like remote drives - there is no way for the storage sharing features to work.
Opening and saving the message the second time really does not make much sense - why not simply copy the MSG file using the file system API?

Handle File.write insufficient disk space

I am developing an application for both Android and iOS. In this application, I download images from the remote server which the user can view them. Now, my question is that when we develop native applications, if the storage space is insufficient, then during file write, it will throw an exception.
Now, similarly when we are doing the same in Appcelerator, file.write(blob), if the disk is not sufficient, will the call throw can exception, or do we need to check for the return value to confirm that it has been written properly.
Soumy, you will need to check the return value.
If you looked in the SDK source code you will see that the native exception for both Android/iOS is send as a false value, through the Kroll Proxy.
You can check here for the File.write implementation on JAVA and
here for the File.write implementation on Obj-C
There is the method spaceAvailable inside Ti.Filesyste.File (https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Filesystem.File-method-spaceAvailable). You could use that the create a manual check before saving the file if you know how big it is

How to create a UI.inputbox which prompts for browse path? [SketchUp 8 API]

I have a ruby script for SketchUp 8 which collects data and needs to write it into a csv file. When the code creates the csv file, I want an inputbox to show up which asks for the filename and directory to save too.
Does anyone know how to create an inputbox with the 'browse directory' option?
UI.inputbox is a very simple and limited API method - it only allow textbox input and dropdown selectionbox input as described in the API docs: http://ruby.sketchup.com/UI.html#inputbox-class_method
But there are other methods for opening the file dialogs:
UI.savepanel http://www.sketchup.com/intl/en/developer/docs/ourdoc/ui#savepanel
UI.openpanel http://www.sketchup.com/intl/en/developer/docs/ourdoc/ui#openpanel
There are no further customization offered than what is described in the API docs.
If you need to design you own custom dialog then you have to resort to either webdialogs (http://www.sketchup.com/intl/en/developer/docs/ourdoc/webdialog - https://github.com/thomthom/sketchup-webdialogs-the-lost-manual) or making your own Ruby C Extension and make system calls natively (https://github.com/SketchUp/ruby-c-extension-examples).

Debugging issue with BlackBerry

I want to print customer Log messages to log file. I have used following code snippet in my BlackBerry application main method.
EventLogger.register(0xaa21388c0c6ee7a7L, TAG, EventLogger.VIEWER_STRING);
String myName = "AnujaAroshA";
if (EventLogger.logEvent(0xaa21388c0c6ee7a7L, myName.getBytes())) {
System.out.println(" #### Log Successful!");
}
It prints "Log Successful" message on the console when my App is running on the real device. Real device is connected to my PC using a USB cable.
Then I tried to copy the log messages in to a text file using command line like follow.
javaloader eventlog > log.txt
After running this the device get freeze as well as the command line. I am developping using Eclipse and in Windows 7 OS.
When I unplug the device and reconnect it and run the same command, it will generate the file with some logs. But in that log file I cannot find 0xaa21388c0c6ee7a7L which is my application GUID.
Where I have made mistakes?
The GUID is used to efficiently represent the tag you want to use with the event logger. When using javaloader, it will format the log entries with the tag you set when registering the GUID with the event logger. So you won't see the GUID value, you will just see the TAG. Make sure your TAG is unique.

Resources