Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Freeze DLL vFlash Call

Hello, i want to control vFlash with LabVIEW.

Vector provide a API to control it but it is not implemented to using it with LabVIEW. I have wrote a Library to call the API to Flash my ECU. Hovewer by step LoadFlash LabVIEW complete Freeze and i must shut it down with the Task Manager.

 

Here is my LabVIEW code and DLL Library Code:

 

 

using System;
using Vector.vFlash.Automation;

namespace vFlash
{
    public class ECU : IDisposable
    {

        private long projectHandle; // Define a private backing field.
        public string ECUname { get; private set; }
        public string ProjectPath { get; private set; }
        public long ProjectHandle { get; set; }
        public uint ChannelID { get; private set; }        
        public uint PercentProgress { get; private set; }
        public uint TimeRemaining { get; private set; }
        public VFlashStationStatus Status { get; private set; }
        public VFlashStationResult Result { get; private set; }

        public ECU(string Name, string projectPath, uint channelID)
        {
            ECUname = Name;
            ProjectPath = projectPath;
            ChannelID = channelID;
            TimeRemaining = 0;
            PercentProgress = 0;
        }

        public VFlashStationResult Initialize()
        {
            VFlashStationResult initializeResult = VFlashStationAPI.Initialize();
            return initializeResult;
        }

        public VFlashStationResult LoadFlash()
        {
            long projectHandle = ProjectHandle;
            VFlashStationResult loadFlashResult = VFlashStationAPI.LoadProjectForChannel(ProjectPath, ChannelID, out projectHandle);

            ProjectHandle = projectHandle;
            return loadFlashResult;
        }
        public VFlashStationResult StartFlash()
        {
            VFlashStationResult startResult = VFlashStationAPI.Start(ProjectHandle, progressCallback, statusCallback);
            return startResult;
        }

        private void progressCallback(long ProjectHandle, uint progressInPercent, uint remainingTimeInSeconds)
        {
            PercentProgress = progressInPercent;
            TimeRemaining = remainingTimeInSeconds;
        }

        private void statusCallback(long ProjectHandle, VFlashStationStatus flashStatus)
        {
            Status = flashStatus;
        }

        public VFlashStationResult Deinitialize()
        {
            VFlashStationResult deinitializeResult = VFlashStationAPI.Deinitialize();
            return deinitializeResult;
        }
        public VFlashStationResult UnloadProject()
        {
            VFlashStationResult unloadResult = VFlashStationAPI.UnloadProject(ProjectHandle);
            return unloadResult;
        }
        public void Dispose()
        {

            GC.SuppressFinalize(this);
        }

        // Finalizer (destructor)
        ~ECU()
        {
            // The finalizer should only be used if the Dispose method is not called.
            // In this case, it is responsible for releasing any unmanaged resources.
            Dispose();
        }
    }
}

 

 

And my LabVIEW Code:

vflashlabview.png

 

Can you give me a advice how to solve this?

 

Thank You

0 Kudos
Message 1 of 2
(1,478 Views)

I have do some work and write a vFlash VIs, i became no error but still dont work. I have attached all my vFlash VIs.

Can you help me where I have an Error?

0 Kudos
Message 2 of 2
(1,321 Views)