freeMASTER scripting

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

freeMASTER scripting

7,527 Views
vpandey1
Contributor I

Hi there

I'm new to using freeMASTER & would appreciate if someone can help with following

1. How to use a command line to issue START command to freeMASTER to start with logging. For our test application running NI labview, command needs to be issued to freeMASTER to start the data logging. The unit under test is connected to PC through USB port and at power up embedded code will start with internal checks on unit & start outputting messages on USB com port. The power up is done using labview code.

2. Once data is logged need to save logged data to excel file. Please help on how to save data to excel file.

 

Thanks

Vinod

Tags (1)
0 Kudos
Reply
15 Replies

7,280 Views
vpandey1
Contributor I

Hi Michal

PCB is based on Kinetics device and supports freeMASTER communication. I'm not familiar with JavaScript, do you have an example in python script? . I'm looking for example to issue "START" command to start the FreeMASTER & once test is complete then issuing a command to log the defined variables data into excel file.

My requirement for using freeMASTER is for production environment and the design team would like us to use freeMASTER. Scripting is preferred option to automate the use of freeMASTER.

Thanks

Vinod

0 Kudos
Reply

7,280 Views
iulian_stan
NXP Employee
NXP Employee

Hi vpandey@dynamiccontrols.com‌,

I have attached a python (v3) version of the JS example provided by Michal. Note: you need to install some additional dependencies specified in requirements.txt.

To answer other questions:

  • "START" command to start the FreeMASTER - you start it as a standard Windows process:
   START "C:\NXP\FreeMASTER 3.0\FreeMASTER\pcmaster.exe" "path_to_your_project.pmpx"
  • log the defined variables data into excel file - you'd need to use a 3rd party python module to interact with excel file
Hope this helps,
Iulian
0 Kudos
Reply

7,280 Views
vpandey1
Contributor I

Hi Lulian

Like START command to start as window process , Is there a command to STOP the freeMASTER ? that is to stop data logging. 

Thanks

Vinod

0 Kudos
Reply

7,280 Views
iulian_stan
NXP Employee
NXP Employee

Hi Vinod,

Assuming your application flow looks like the one in the picture bellow:

Untitled.png

it's up to you when the data logging should be stopped (it is basically controlled by your script). If you want to Stop FreeMASTER just kill the process: taskkill /IM pcmaster.exe (assuming you have only one instance of Fmstr running on the PC, otherwise you'd need to obtain the PID and use it with taskkill command).

Note: the same can be achieved with Python as well (subprocess.Popen/os.kill), or any other external application.

Btw, have you heard about FreeMASTER Lite (it's a light weight NodeJS wrapped build on top of the FreeMASTER communication library). It has no UI, and you could run it in the background without the need to each time start/stop the process (the flow would be just as above, but without first and last nodes).

Regards,

Iulian

0 Kudos
Reply

7,280 Views
vpandey1
Contributor I

Hi Lulian

Thanks for explanation. I'm planning to use labview active-x to issue command & log data.

Selecting pcmaster active -x class "McbPcmLib.IMcbPcm" issuing of commands & logging data may be possible.

I saw in post someone tried this earlier.

I'm told by design that for our application freeMASTER will just be listening /  reading the data on USB and variables as defined in elf file will get the values. Then the variables to be written to csv file. 

I feel steps may be like below

1. START command is issued to freeMASTER ( Python or labview)

2. UUT is powered up & goes into test mode and starts sending data to freeMASTER as test goes.

3. At test finish STOP COMM command is issued to freeMASTER & data in variables is written to CSV file.

Thanks

Vinod

0 Kudos
Reply

7,280 Views
vpandey1
Contributor I

Hi Lulian

I have further query regarding reading variables, I'm trying labview active-x & able to open project when open Project command is given to open the freeMASTER project. My question is that say if project is open but I don't have a physical board with me. I can see variables in the watch window. Is there any freeMASTER command available to save the variable values in off line mode - just want to simulate commands while waiting for board being built.

Thanks

Vinod

0 Kudos
Reply

7,278 Views
iulian_stan
NXP Employee
NXP Employee

Hi Vinod,

Unfortunately, FreeMASTER has no "offline" mode, nor similar functionality. (It always expects the board to be connected, otherwise function calls fail with timeout error).

Regards,

Iulian

0 Kudos
Reply

7,276 Views
vpandey1
Contributor I

Hi Lulian

I have a question regarding "active-x" - write variable method. I would like to update a variable value using active-x but unable to do so as not sure How to press "Enter" using active -x or rather combine the value with enter so the value can get updated , when doing manually value gets updated after I enter new value & press Enter from keyboard.

I am able to read values using "Read Variable" method.

Please suggest.

Thanks

Vinod

0 Kudos
Reply

7,276 Views
iulian_stan
NXP Employee
NXP Employee

Hi Vinod,

To write a value, you just need to call the WriteVariable function using the predefined variable name and desired value (ex: pcm.WriteVariable('var16inc', 10);), no other operations are required. To catch any errors during the write operation you could use the full function signature WriteVariable ([in] var, [in] value, [out] retMsg) (Ch. 6.5.13 of the User Manual), where the last argument is an output value that would carry the error message. You can also access this value using direct ActiveX object property LastRetMsg (Ch. 6.6 UM).

Could you first check your call for any errors ?

Regards,

Iulian

0 Kudos
Reply

7,278 Views
vpandey1
Contributor I

Hi Lulian

There was an issue with my command format & problem got resolved.

What 'Exit' active-x command does?

Thanks

Vinod

0 Kudos
Reply

7,278 Views
iulian_stan
NXP Employee
NXP Employee

It instructs the FreeMASTER application to quit. Equivalent to pressing the Exit option in File menu.

Untitled.png

Regards,

Iulian

0 Kudos
Reply

7,278 Views
vpandey1
Contributor I

Hi Lulian

Can you please tell- How can I fix the PC's comm port used by freeMaster application? connected to kinetics MKE14Z based micro.

During testing of units we find that freeMaster comm port number changes from unit to unit.

Or else Is there a script command available in active-x to define or set comm port in freeMaster - basically same as we do manually by going into Project ---> options. I can read the comm port number using dos batch command & then can set the port number in freeMaster if a command is available.

I could not find StartComm commands in active-x which is given in the manual.

Regards

Vinod

0 Kudos
Reply

7,278 Views
MichalH
NXP Apps Support
NXP Apps Support

Dear Vinod,

the USB/COM port numbers are assigned by Windows system. FreeMASTER cannot change the number. However, for the desktop FreeMASTER application, there is one trick that could help you.

You do not need to specify the COM port by exact number like COM65 (see the picture below). You can use any word or sub-string from the port's description text, that is displayed next to the port number in FreeMASTER Options dialog. This text is always the same for the same kind of port, even if number changes when you plug-in a different board (of the same kind). In order to make the identification unique, you just need to pick a word from the description which is not contained in other ports' descriptions. 

pastedImage_1.png

Regards,

Michal

0 Kudos
Reply

7,278 Views
vpandey1
Contributor I

Thanks Michal

0 Kudos
Reply

7,278 Views
MichalH
NXP Apps Support
NXP Apps Support

Dear Vinod,

FreeMASTER is not able to just capture and log any traffic that your embedded application generates on the USB/COM port. FreeMASTER uses a communication protocol to exchange commands and responses with the target device over Serial line, CAN or other support transport. The target device should support the FreeMASTER protocol. Please read the FreeMASTER User Guide or watch some introduction videos to find more details about the FreeMASTER basic features. 

If your device already supports the FreeMASTER communication, then you can write a simple node.js or Python script which will automate the FreeMASTER application to open the communication and start capturing the variable data. And well, when working with at raw command-line level and scripts, I would not use FreeMASTER desktop application to log data to file. You have more options and freedom to do any arbitrary data capture and logging in the script directly.

Attached, you can see a simple node.js script which reads a single variable named "var16". Look for the read-single-var.js file.

Best regards,

Michal

0 Kudos
Reply