Json RPC Server StartComm

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Json RPC Server StartComm

跳至解决方案
807 次查看
Ickes
Contributor I

Hi,

I am using matlab and freemaster rpc-server for automatic data logging.

I tried to get all the information from the freemaster lite JS api because there is no rpc-server api where the json structures for the commands are defined or at least I could not find it.

 

So far it has worked and I can read and write variables and stop the communication, but the structure to start communication does not work. Does anyone here have an idea what is wrong with this?

jsonMessage2(1).jsonrpc="2.0";
jsonMessage2(1).method="StartComm";
jsonMessage2(1).params=["comm_plugin_conn","name","addr=localhost;port=9990;timeout=500","string"];
jsonMessage2(1).id=0;

The error message is: msg: 'StartComm: Could not open the communication port (Error 0x848a0001: Connect string invalid.) !'

I got the connection string from the freemaster desktop application running with an existing freemaster project, in the UI I can start the communication without problems.

 

0 项奖励
1 解答
769 次查看
iulian_stan
NXP Employee
NXP Employee

Hi @Ickes,

StartComm expects a single argument - connection string:

Capture.PNG

It can be passed as positional or named argument.
In your case the message could look like this (assuming the target is connected to you PC via UART):

 

(positional):

jsonMessage2(1).jsonrpc="2.0";
jsonMessage2(1).method="StartComm";
jsonMessage2(1).params=["RS232;port=COM1;speed=115200"];
jsonMessage2(1).id=0;

(named):

jsonMessage2(1).jsonrpc="2.0";
jsonMessage2(1).method="StartComm";
jsonMessage2(1).params={"name": "RS232;port=COM1;speed=115200"};
jsonMessage2(1).id=0;

Currently, there is no explicit description of the JSON messages. The message can be inferred from the JS client y following these 2 rules:

  1. `method` property is the same as JS function name
  2. `params` is an array of properties following the same order in which they appear in JS function definition or an JSON object. In the second case, object properties are the same as JS function arguments (no restriction on order in this case).

Hope it helps,
Iulian

在原帖中查看解决方案

0 项奖励
2 回复数
741 次查看
Ickes
Contributor I

Hi @iulian_stan,

thank you for your reply. I am using the FreeMASTER tcp to serial plugin and found a way to start the communication.

With the plugin the necessary string consists of the comm-plugin-id followed by the comm-plugin-string

''' StartCommMessage(1).params=["{comm-plugin-id};comm-plugin-string","name"];

0 项奖励
770 次查看
iulian_stan
NXP Employee
NXP Employee

Hi @Ickes,

StartComm expects a single argument - connection string:

Capture.PNG

It can be passed as positional or named argument.
In your case the message could look like this (assuming the target is connected to you PC via UART):

 

(positional):

jsonMessage2(1).jsonrpc="2.0";
jsonMessage2(1).method="StartComm";
jsonMessage2(1).params=["RS232;port=COM1;speed=115200"];
jsonMessage2(1).id=0;

(named):

jsonMessage2(1).jsonrpc="2.0";
jsonMessage2(1).method="StartComm";
jsonMessage2(1).params={"name": "RS232;port=COM1;speed=115200"};
jsonMessage2(1).id=0;

Currently, there is no explicit description of the JSON messages. The message can be inferred from the JS client y following these 2 rules:

  1. `method` property is the same as JS function name
  2. `params` is an array of properties following the same order in which they appear in JS function definition or an JSON object. In the second case, object properties are the same as JS function arguments (no restriction on order in this case).

Hope it helps,
Iulian

0 项奖励