MartinMcD Posted August 7, 2013 Report Share Posted August 7, 2013 I've created a Windows service from an executable that writes a nonsense value to a network shared variable. What I want to do is read a number from a serial device and write that value instead. It doesn't seem to work and this link suggests it is not going to: http://digital.ni.com/public.nsf/allkb/38128C80B42DBB8486256F3A006DECFF Does anyone know of a workaround for this, ie accessing a port using VISA from within a service? I assume the answer is 'no' but it'd be so useful for my project that its worth checking. Its a continuously running thing and it needs to work when nobody is logged on - hence the service. Thanks, Martin Quote Link to comment
MartinMcD Posted August 7, 2013 Author Report Share Posted August 7, 2013 I should have said, otherwise I think I will have to convert the PC to run as a real-time device, which is just a bit of a hassle time-wise. Quote Link to comment
Mads Posted August 8, 2013 Report Share Posted August 8, 2013 (edited) We've converted most of our applications into services on regular Windows (95/Vista/7/8) targets using srvany, and they work without any modifications. Are you sure the app works properly in the first place, before being converted into a service? Does it rely on access to configurations e.g that it might not have access to when it starts up as a service? If that configuration file is expected to be in a system folder the servic emight not refer to the same folder...) The link you posted talks about VISA server, not the VISA-RunTime...and it's the RunTime that's needed for the service to access a local serial port. Edited August 8, 2013 by Mads Quote Link to comment
Rob Calhoun Posted August 8, 2013 Report Share Posted August 8, 2013 Likewise we run our LV applications as services using FireDaemon and have not had any trouble reading from serial ports using VISA under Windows Server 2003, 2008, or 2008R2. (At least not any trouble that can be blamed on running as a service...we did have an issue where the Microsoft Mouse Driver identified our GPS device as a serial mouse!) -Rob Quote Link to comment
MartinMcD Posted August 8, 2013 Author Report Share Posted August 8, 2013 (edited) Ahh great, thank you for the responses. I realised my error and it's working perfectly now - thanks for the encouragement! (Out of interest, the problem vi was based on my method for processing the raw data coming from the serial port. It reads a value from a text file on a network drive. I forgot about this - the service isn't allowed to access the drive so it was just returning zero.) Edited August 8, 2013 by MartinMcD Quote Link to comment
MartinMcD Posted August 8, 2013 Author Report Share Posted August 8, 2013 Also, is there a mechanism for sending an event to the service so it can stop gracefully? I'm having problems caused by not closing the VISA session for my serial ports when calling 'net stop', if an event could be passed I could close the port properly. Quote Link to comment
ShaunR Posted August 8, 2013 Report Share Posted August 8, 2013 Also, is there a mechanism for sending an event to the service so it can stop gracefully?I'm having problems caused by not closing the VISA session for my serial ports when calling 'net stop', if an event could be passed I could close the port properly. There's a setting in the labview options under environment that should sort that out (it puts cleanupVisa=True in the ini file). Automatically close VISA sessions—Automatically closes VISA sessions left open by the application when the top-level VI becomes idle. This checkbox does not contain a checkmark by default. Quote Link to comment
MartinMcD Posted August 9, 2013 Author Report Share Posted August 9, 2013 Great, thank you for that, hopefully that'll fix my problems. Quote Link to comment
Mads Posted August 9, 2013 Report Share Posted August 9, 2013 We've never experiences any VISA problems from shut-downs...but if the software required actions to be done prior to quitting, I do not think the application instance close event would do the trick, it does not seem to fire when the service is quit from the services panel. Does anyone have a way to filter/intercept such an event and run shutdown code? PS. Uou should also have RunAsService=True in the executables ini-file so that the service ignores any user logoffs (see http://www.ni.com/white-paper/3185/en). Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.