I need to Integrate Cognex Dataman Wireless Handheld scanner in to existing Application developed using LabWindows CVI. Cognex has provided SDK in C#. Below SDK link
http://www.cognex.com/support/downloads/File.aspx?d=2628
I used CVI Tool .Net Controller to create C# Wrapper.
http://zone.ni.com/reference/en-XX/help/370051T-01/cvi/libref/cvidotnet_sample_code/
Below is code that suppose to connect to cognex scanner.
Cognex_DataMan_SDK_EthSystemConnector__Create (&DM_Connector, IPAddress,0);
Cognex_DataMan_SDK_EthSystemConnector_Set_UserName (DM_Connector,"Admin", 0);
Cognex_DataMan_SDK_EthSystemConnector_Set_Password (DM_Connector, "", 0);
Cognex_DataMan_SDK_DataManSystem__Create (&DM_system, DM_Connector, 0);
Cognex_DataMan_SDK_DataManSystem_Connect (DM_system, 0);
My problem is below line
Cognex_DataMan_SDK_EthSystemConnector__Create (&DM_Connector, IPAddress, 0);
I can create execute but it's not connecting, Constructor is not taking ipaddress.
Below help on generate from C# Wrapper Prototype
/*
Creates a new instance of the ethernet connector with the specified system IP address.
-------------------- Prototype
int Cognex_DataMan_SDK_EthSystemConnector__Create
(Cognex_DataMan_SDK_EthSystemConnector *Instance_Handle,
System_Net_IPAddress address,
CDotNetHandle *Exception_Handle);
Please advise , I have no success so far with this
Thank You
Related
I wrote a console app on .NET, to read without consuming the messages from an IBM MQ queue.
Worked perfect.
Now, I need to migrate that app into .NET Core. Can't figure out why it is extremely slow.
How it works:
target framework .NET Core 3.1
IBMMQDotNetClient NuGet package installed
created a helper class, static, with a static constructor where I initialise MQEnvironment properties like so:
MQEnvironment.CertificateLabel = "ibmwebsphere"; // this is the friendlyname on mmc certificate
MQEnvironment.SSLKeyRepository = "*SYSTEM";
added a method called Init where I initialise connection to MQManager like so:
Hashtable properties = new Hashtable();
properties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
properties.Add(MQC.HOST_NAME_PROPERTY, hostName); // I read the hostName from a config file
properties.Add(MQC.PORT_PROPERTY, port); // I read the port from a config file
properties.Add(MQC.CHANNEL_PROPERTY, channelName); // I read the channel from a config file
properties.Add(MQC.SSL_CIPHER_SPEC_PROPERTY, cipherSpec); // I read the cipher spec from a config file, it's something like TLS_RSA_WITH_AES_256_CBC_SHA256
Then, I'm going to create a connection to the queue manager using the connection, and read messages one by one until coming to end of the queue.
var queueManager = new MQQueueManager(qm, properties); // I read the qm from a config file
var queue = queueManager.AccessQueue(queueName, MQC.MQOO_BROWSE + MQC.MQOO_FAIL_IF_QUIESCING); // I read the queueName from a config file
var mqGMO = new MQGetMessageOptions();
mqGMO.Options = MQC.MQGMO_FAIL_IF_QUIESCING + MQC.MQGMO_NO_WAIT + MQC.MQGMO_BROWSE_NEXT; mqGMO.MatchOptions = MQC.MQMO_NONE;
try {
while (true) {
MQMessage queueMessage = new MQMessage();
queue.Get(queueMessage, mqGMO); // code gets apparently stuck on this line,
// overprocessing, for many minutes until it gets to the next line,
// even though I mentioned "NO_WAIT" in the options.
// Note this only happens for .NET Core, but not in .NET framework.
var message = queueMessage.ReadString(queueMessage.MessageLength);
string fileName = message.Substring(0,3); // some processing here to extract some info from each message
}
}
catch(MQException ex)
{
if(err.ReasonCode.CompareTo(MQC.MQRC_NO_MSG_AVAILABLE) == 0)
{
// harmless exception to indicate there are no messages on the queue
}
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
Of course it would be preferable to use a listener, not sure how to do that yet, it would be part of optimising, but for now - why is working so slow on line:
queue.Get(queueMessage, mqGMO); // but, again, as mentioned, only with the amqmdnetstd.dll (.NET Core), because if I use amqmdnet.dll (.NET framework), it works super fast, and it's supposed to be the other way around.
I do need to use .NET Standard/Core because I will run this in Linux, currently testing in Windows.
Don't use the MQEnvironment class as it is not threaded safe. Also, don't mix and match between MQEnvironment class and using MQ HashTable. Put your SSL/TLS information as a property in the MQ HashTable.
i.e.
properties.Add(MQC.SSL_PEER_NAME_PROPERTY, "ibmwebsphere");
properties.Add(MQC.SSL_CERT_STORE_PROPERTY, "*SYSTEM");
There isn't enough of your code to test to see why it might be failing.
I wrote and posted a blog item called: IBM MQ For .NET Core Primer. In the blog post, I included a fully functioning C# MQ example (MQTest62L.cs) that was built and run using .NET Core v3.1 and everything worked perfectly (see very bottom of post). Hence, I would suggest you follow my instructions, download, compile and run MQTest62L.cs to see if the issue is your code or MQ Client library.
Note: I was using Windows 10 Pro, IBM MQ v9.2.0.0 and .NET Core v3.1.415.
I am trying to access the GPIO on my custom SBC using Windows 10 IoT Core. I have discovered that I must use LightningProviders to accomplish this . So I tried to follow this guide to use lightning providers properly.
I used very simple code:
if (LightningProvider.IsLightningEnabled)
{
LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider();
}
GpioStatus = "Initializing...";
var gpio = GpioController.GetDefault();
if (gpio == null)
{
GpioStatus = "There is no GPIO controller on this device.";
}
else
{
gpio.OpenPin(1).Write(GpioPinValue.High);
GpioStatus = gpio.OpenPin(1).Read().ToString();
}
Where GpioStatus is output text on a UI.
I discovered that if I run the LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider(); line outside of the enabled check, it picks up the GPIO controller and lets me detect how many pins I have and read them (All low). However I can't change the DriveMode or write to the pins without error. The error I get just says to Make sure the LightningProviders are enabled.
This brings me back to the guide I linked at the start. It suggests to enable DMAP drivers using the Device Portal for W10IoT or DMAPUtil.exe. I have tried both. In the Device Portal the area where it should be is just blank. And in the command line trying to use the DMAPUtil.exe only returns that dmaputil.exe is not available on this system.
Therefore I am asking if there is any other way to enable the LightningProviders or if there a way to know if they are incompatible with my board?
Thanks!
UPDATE
Also tried using the devcon.exe commands in the W10IoT Command line.
I am able to locate the Direct memory access controller but when i do devcon.exe enable *PNP0200 it says it is enabled but remains disabled when checked with devcon.exe status *PNP0200
Please confirm if you have added the IOT_DMAP_DRIVER feature in your OEMInput.xml, this feature will add the DMAP driver in the image. If IOT_DMAP_DRIVER is removed from the OEMInput.xml, the Default Driver Controller will be blank in device protal, and dmaputil will be not available on Windows IoT Core. Please see the IoT Core feature list.
Update:
You can download the source of Lighting Provider, and then deploy and debug in your custom image.
I'm trying to connect to barcode scanner (is a HID device). I was able to receive data using RawInput, but I want to try using CreateFile().
deviceInformation.ReadHandle = Kernel32.CreateFile(
deviceInformation.DevicePathName,
Constants.GenericRead,
Constants.FileShareRead | Constants.FileShareWrite,
IntPtr.Zero,
Constants.OpenExisting,
Constants.FileFlagOverlapped,
0);
int it = Marshal.GetLastWin32Error();
CreateFile() returns this:
Marshal.GetLastWin32Error() returns 5 which is ERROR_ACCESS_DENIED
I'm using this source code as the reference.
My questions are: Is it possible to create a handle to that hid device using CreateFile()? If yes, why do I receive Access denied? and what is the correct way to create a handle?
PS: Windows 10, Visual Studio 2015
Anyone know if it can recover the ( hostname/machine name ) with a local IP address ? I know that the resolution reverse 'hostname -> ip' works perfectly with DeviceNetworkInformation.ResolveHostNameAsync (endpoint, OnNameResolved, null).
Is it possible to do the same thing but in reverse? Given the IP of a Local Machine and retrieve its hostname? A thousand thanks
Here is my code , but it's doesn't work the host is always called "192.168.1.5" like the ip . And it's should return "computer0001"
DeviceNetworkInformation.ResolveHostNameAsync("192.168.1.5", OnNameResolved, null);
private void OnNameResolved(NameResolutionResult result)
{
IPEndPoint[] endpoints = result.IPEndPoints;
if (endpoints != null)
{
if (endpoints.Length > 0)
{
//Host always return ip adress and not the machine name
host = endpoints[0].ToString();
}
}
}
Not sure if there is specific API on Windows Phone for that purpose.
I suggest you looking into similar question 'DNS lookup from custom DNS server in c#'.
If you're okay with going only WP8, then you should study this part of MSDN - Supported Win32 APIs for Windows Phone 8.
For example, getpeername function might return you information you're looking for. Or you might create new HostName object passing IP address there and trying to read DisplayName, CanonicalName or RawName properties of it.
Make sure you test with both emulator and real device as WP8 emulator has a little bit complex network configuration.
Would be great if you can update us if you have any success with the task.
VBoxManage.exe is an Oracle VirtualBox companion utility, which allows to control VMs via command line. It can do numerous operations, including start/stop and screen capturing.
I am interested, which API it uses?
How can I capture VM screen or send keyboard or mouse commands there without this heavy commandline utility? Which language is better? Is is possible to access this API with Java?
One of the advantages to using an open source project is supposed to be that you can answer such questions by looking at the source.
VBoxManage is located in the source repository under /src/VBox/Frontends/VBoxManage. The code you're looking for is in VBoxManageControlVM.cpp under the condition if (!strcmp(a->argv[1], "screenshotpng")):
ComPtr<IDisplay> pDisplay;
CHECK_ERROR_BREAK(console, COMGETTER(Display)(pDisplay.asOutParam()));
ULONG width, height, bpp;
CHECK_ERROR_BREAK(pDisplay,
GetScreenResolution(displayIdx, &width, &height, &bpp));
com::SafeArray<BYTE> saScreenshot;
CHECK_ERROR_BREAK(pDisplay, TakeScreenShotPNGToArray(displayIdx,
width, height, ComSafeArrayAsOutParam(saScreenshot)));
RTFILE pngFile = NIL_RTFILE;
vrc = RTFileOpen(&pngFile, a->argv[2], RTFILE_O_OPEN_CREATE | RTFILE_O_WRITE |
RTFILE_O_TRUNCATE | RTFILE_O_DENY_ALL);
if (RT_FAILURE(vrc))
{
RTMsgError("Failed to create file '%s'. rc=%Rrc", a->argv[2], vrc);
rc = E_FAIL;
break;
}
vrc = RTFileWrite(pngFile, saScreenshot.raw(), saScreenshot.size(), NULL);
if (RT_FAILURE(vrc))
{
RTMsgError("Failed to write screenshot to file '%s'. rc=%Rrc",
a->argv[2], vrc);
rc = E_FAIL;
}
RTFileClose(pngFile);
So it's done via a COM API, and you can look at:
Is it possible to call a COM API from Java?
Googling for TakeScreenShotPNGToArray finds the display interface:
https://www.virtualbox.org/sdkref/interface_i_display.html
From there you can find the list of all the other things like mouse and keyboard:
https://www.virtualbox.org/sdkref/annotated.html