Creating the CODESYS 3.5 I/O driver - windows

I have a PLC running on Windows CE 7, I need to connect a HID joystick to it. I created a driver for the joystick and now I need to transfer data to CODESYS Control (3.5.15.30). After studying some information, I realized that I should create a new I/O driver for CODESYS, but I have little experience in such matters. I found one project in which this is implemented, but the source code of the dll library is missing, and I could not find detailed instructions for creating a driver. Maybe someone has already done this and can help me?

Related

Monitor process resources on Windows CE 5.0

I'm developing a WinCE 5.0 application that uses two commercial libraries. When the application starts calling the second library it gets slowlier and then after some use, it hangs and the whole OS freezes. It has to be rebooted to work again. The thing is that I'm developing this without a physical device (a testing person installs each release and runs the tests) and without an emulator (the device provider is not facilitating an OS image).
My intuition tells me that the second library is using all the available resources (basically, handles and memory) for a WinCE 5.0 process. I have to prove this to the library vendor. So I wish to add to my logs some general process and system information. Could you recommend me which APIs to call to get this information in CE?
I would really appreciate any hint
Thanks in advance!
Windows CE provides a very robust set of APIs for a subsystem called CeLog. CeLog is what Kernel Tracker uses to collect and display it's information. You can get all the way down to scheduler calls and thread migrations if you want. The real danger with using CeLog is in collecting too much data so that making sense of it is difficult, but if you filter the collections to just your process, that should help. You could collect the data to a log file, then use Kernel Tracker to open and view that data.
Here are some good starting points for info:
Introduction to Remote Kernel Tracker
More on Remote Kernel Tracker
CeLogFlush.exe (particularly the section 'Collecting Data on a Standalone Device with CeLogFlush')
Implementing a Custom Event Tracking Library
Embedded Visual C++ 4 contained "Remote Performance Monitor" that could do just that. Microsoft retracted EVC4 as free download some time ago, but it can still be downloaded from MSDN or found on the internet.
With service pack 4 it should work for WinCE 5.0. It does not appear to work with Windows Embedded 6.0 and newer though.

How to start learn linux device driver development?(worked on windows only)

I want to learn Linux device driver development.
Positives:
I have developed small drivers on WinCE and worked on SPI, i2c interface from application i.e. opening, reading and writing driver.
I'm good in operating system and data structures.
Negatives:
I have never worked on Linux.
My background is not embedded system.
How should I proceed to learn Linux device driver development?
EDIT: any book reference would be appreciable thanks
Linux Device Drivers, Third Edition : http://lwn.net/Kernel/LDD3/ should help you along.
THE FOLLOWING LINKS WILL HELP TO START LEARNING DEVICE DRIVERS
http://www.freesoftwaremagazine.com/articles/drivers_linux
http://lwn.net/Articles/driver-porting/

Windows driver creation

I would like to try creating a custom driver for a trackpad of mine. Could you please recommend an opensource driver to start with? My search turned out nothing, so I hope there actually any skeleton code to begin building from.
Is it a USB HID device? If so, it should be pretty easy to read data from the device.
Check out this code (C#) for example.
There is also the UMDF (User Mode Driver Framework) that supposedly allows writing drivers for USB-like devices in user mode. I have never used it though. There are a couple of sample drivers to download.

New driver installation on Windows

I am trying to find what happens when new driver is installed for windows. (What kernel data structures are modified.) Does anyone know any good documentation on this topic. It is a bit painful to debug this.
Thanks
When a driver is installed is it placed into the Driver Store (see http://msdn.microsoft.com/en-us/library/ff544868%28v=vs.85%29.aspx)
When a new device is discovered that does not have a current driver association the PNP manager looks at the driver store to see if any of the stored drivers will match the new device.
If the PNP manager finds a driver to match the device it will execute the directives in the drivers inf file. This typically creates a service entry in the registry (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services), copies the driver binaries to somewhere like \Windows\System32\drivers etc. Also the PNP manager will create an association of that device to that driver (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum I think) so that next time it can shortcut the process.
I don't think any kernel data structures are modified when a driver is installed. Do you mean to ask when a driver is loaded?

Installing a driver using Inno Setup

I'm creating setup for my application in Inno Setup, and I will probably need to install driver sometime in the future. However, I need to know some tips about installing drivers in Inno Setup now, so I can easily add the driver into the setup when it's needed.
Should I force the user to install program only into C:\Program Files\<app>\, or it doesn't matter and I should let him install it even on network drive?
Should I install the driver in C:\Windows\, to make it available anytime (even without network drive), or it doesn't matter as well?
Is it possible to start driver on-demand? I want to release new versions of my program, and I need to create the setup so it doesn't require reboot after updating my app. So is it possible to shutdown the driver, overwrite it with new version, and turn on again (as you can with services) without restarting Windows?
Is it possible to overwrite the driver so easily (as mentioned in question 3), or is it recommended to always fully uninstall the program, and then again install the new version?
Could you please include some additional tips about installing/uninstalling/updating drivers you find important? I'm sure I've missed some important points.
I don't have much driver-experience nor knowledge, so I apologize for somewhat confused questions.
And it is probably important what kind of driver would it be, so there is a related question, which should answer that:
Low level mouse hook and DirectX
Driver Development Resources
I've found some helpful links regarding driver development. Use this as a reference.
Driver Development at CodeProject - Part 1, Part 2, Part 3, Part 4, Part 5, Part 6
http://www.catch22.net/tuts/kernel1.asp
Introduction to Device Drivers
Windows Driver Development Tutorial
Please don't do this, installing an upper-level filter driver on all HID devices is an extraordinarily bad idea. That being said, I'll answer your questions anyways.
When you install a driver, Windows manages where the driver itself gets put (in DriverStore), you don't worry about this.
See #1
For some drivers, yes. For a filter driver above HID, no. You'd have to force remove all mice and keyboards on their system and re-add them (which isn't possible with PS/2 devices).
Yes, it's fairly easy to update a driver given that you correctly version it and require a reboot.
Once again, while I don't want to be discouraging, you're only going to get yourself in a world of hurt via doing this.

Resources