FREEMASTER interface using ActiveX or JSON RPC

cancel
Showing results for 
Search instead for 
Did you mean: 

FREEMASTER interface using ActiveX or JSON RPC

Jump to solution
204 Views
vulpliks
Contributor I

I am using the S32K144EVB-Q100 Evaluation Board and I am planning to interface the data captured through the FreeMaster tool and Matlab or Python.

 

For this purpose, I am running the example files provided by FreeMaster and it seems to run decently when I have the default demo application. I tested using ActiveX commands on Matlab and JSON RPC commands on Python. That is what is described in the readme file:

"For all examples, have the target board connected and running the default demo application
distributed within the FreeMASTER Serial Driver package."

 

The question is, when I flash any other software into the MCU, even the ones generated by the MBDT Toolbox, the board seems to work fine, even FreeMaster itself works properly for data visualizing, however: the ActiveX and JSON-RPC integration functions do not work anymore and I start getting errors in the Communication Debug Log of FreeMaster.

 

In my opinion, there must be some special configuration I can do for enabling my custom code to interact with ActiveX objects because it makes no sense for me that such an interesting function is only functional for the Demo software.

 

Can someone please tell me what modifications I need to do for running my Matlab/Python scripts and importing variables data with any custom code?

 

Thank you very much.

0 Kudos
1 Solution
185 Views
MichalH
NXP Employee
NXP Employee

Hello,

the FreeMASTER 3.0 generates couple of events on the JSON-RPC interface and it seems your JSON-RPC Python wrapper cannot handle them. Right after opening the port with StartStopComm(), the FreeMASTER will fire an event named OnCommPortStateChanged(). This seems to break the JSON-RPC handler.

I recommend to start using the latest FreeMASTER 3.1 available at nxp.com/freemaster. This version fixes several issues of 3.0 and also it does not fire JSON-RPC events without first being enabled by EnableEvents() rpc call.

The error message in the log saying
Script:StartStopComm(start:true) done [ERROR code=0x80004005]
is actually an issue of FreeMASTER logging - this should be just an informative message. The error report is false. We will fix this issue in a next 3.1.x update.

The next error message
GetTargetSideSymbolInfo(tblindex:0) done [ERROR code=0x80000081]
is correct. It says your target board does not support TSA information (a runtime replacement of ELF symbols parsing). This is not a critical error when your project uses the ELF file.

 

Regards,
Michal

 

View solution in original post

4 Replies
198 Views
MichalH
NXP Employee
NXP Employee

Dear User,

both ActiveX and JSON-RPC servers are always active when FreeMASTER desktop application is running. The interfaces enable 3rd party applications like Matlab, Excel etc. to access methods documented in the FreeMASTER User Guide, Section 6. 

The most common operation executed over the ActiveX or JSON-RPC interface is ReadVariable() or WriteVariable() - which is also demonstrated in the examples. In order to properly execute these calls, the referenced variables must exist in the FreeMASTER project which is currently open. Otherwise you will be getting an "Unknown variable" error.

Can you send what errors you get in the Log or send a screenshot of the problem?

Thanks,
Michal

 

0 Kudos
190 Views
vulpliks
Contributor I

Dear Michal,

 

Thank you for your support.

I am sending you this compressed file containing six individual files.

I am flashing the .mot file into the FS32K144 microcontroller. It is a very simple application, it reads the values of the two switches, SW2 and SW3. If both switches are pressed at the same time, the green LED shall be on, otherwise, nothing happens. This code was generated using the blocks in the Simulink MBDT Toolbox provided by NXP (.mdl file).

The .pmpx file is the Freemaster 3.0 project that I created for visualizing the values of these two switches in the software scope. In the FreeMaster Project > Options > MAP Files, I select the .elf file as the "Default Symbol File". The application works fine.

I created the Matlab .m script for a very simple ActiveX interface test, basically, it only displays the value of the SW2 in the prompt. It seems now that it works, even with my custom code on the board.

However, the .py file is a Python script that uses a Websockets application for using the JSON-RPC methods. The idea here is: Start the Freemaster communication, load the value of SW2 into the variable data and Stop the communication. While using the default demo code into the target, it seems to work fine. But when I load my .mot file into the board and try to run the application, it will give me the following error in the Spyder console:

ValidationError: {'jsonrpc': '2.0', 'method': 'OnCommPortStateChanged', 'params': [True]} is not valid under any of the given schemas

Failed validating 'oneOf' in schema:
    {'$schema': 'http://json-schema.org/draft-04/schema#',
     'definitions': {'common': {'not': {'description': 'cannot have result '
                                                       'and error at the '
                                                       'same time',
                                        'required': ['result', 'error']},
                                'properties': {'id': {'note': ['spec says '
                                                               'a number '
                                                               'which '
                                                               'should not '
                                                               'contain a '
                                                               'fractional '
                                                               'part',
                                                               'We choose '
                                                               'integer '
                                                               'here, but '
                                                               'this is '
                                                               'unenforceable '
                                                               'with some '
                                                               'languages'],
                                                      'type': ['string',
                                                               'integer',
                                                               'null']},
                                               'jsonrpc': {'enum': ['2.0']}},
                                'required': ['id', 'jsonrpc'],
                                'type': 'object'},
                     'error': {'allOf': [{'$ref': '#/definitions/common'},
                                         {'properties': {'error': {'properties': {'code': {'note': ['unenforceable '
                                                                                                    'in '
                                                                                                    'some '
                                                                                                    'languages'],
                                                                                           'type': 'integer'},
                                                                                  'data': {'description': 'optional, '
                                                                                                          'can '
                                                                                                          'be '
                                                                                                          'anything'},
                                                                                  'message': {'type': 'string'}},
                                                                   'required': ['code',
                                                                                'message'],
                                                                   'type': 'object'}},
                                          'required': ['error']}]},
                     'success': {'allOf': [{'$ref': '#/definitions/common'},
                                           {'required': ['result']}],
                                 'description': 'A success. The result '
                                                'member is then required '
                                                'and can be anything.'}},
     'description': 'A JSON RPC 2.0 response',
     'oneOf': [{'$ref': '#/definitions/success'},
               {'$ref': '#/definitions/error'},
               {'items': {'oneOf': [{'$ref': '#/definitions/success'},
                                    {'$ref': '#/definitions/error'}]},
                'type': 'array'}]}

On instance:
    {'jsonrpc': '2.0', 'method': 'OnCommPortStateChanged', 'params': [True]}

 

Besides, in the Freemaster's Communication log I receive the following error:

Script:StartStopComm(start:true) done [ERROR code=0x80004005]
GetTargetSideSymbolInfo(tblindex:0) done [ERROR code=0x80000081]

 

Actually, it successfully starts the communication with Freemaster, I can see it started running, but it does not return the required value. Even if I comment out the portion of the code for reading the value, the same error persists and I do not know why it is happening.

Thanks again

0 Kudos
186 Views
MichalH
NXP Employee
NXP Employee

Hello,

the FreeMASTER 3.0 generates couple of events on the JSON-RPC interface and it seems your JSON-RPC Python wrapper cannot handle them. Right after opening the port with StartStopComm(), the FreeMASTER will fire an event named OnCommPortStateChanged(). This seems to break the JSON-RPC handler.

I recommend to start using the latest FreeMASTER 3.1 available at nxp.com/freemaster. This version fixes several issues of 3.0 and also it does not fire JSON-RPC events without first being enabled by EnableEvents() rpc call.

The error message in the log saying
Script:StartStopComm(start:true) done [ERROR code=0x80004005]
is actually an issue of FreeMASTER logging - this should be just an informative message. The error report is false. We will fix this issue in a next 3.1.x update.

The next error message
GetTargetSideSymbolInfo(tblindex:0) done [ERROR code=0x80000081]
is correct. It says your target board does not support TSA information (a runtime replacement of ELF symbols parsing). This is not a critical error when your project uses the ELF file.

 

Regards,
Michal

 

View solution in original post

178 Views
vulpliks
Contributor I

Dear Michal,

 

Indeed, after I installed the FreeMaster version 3.1, this error disappeared.

 

Thank you again and best regards

0 Kudos