data = await SendRequest(ws, 'GetDetectedBoardInfo')
## print('Detected board info: ' + data) ## Error: TypeError: can only concatenate str (not "dict") to str
print('Detected board info: ')
print(data)
Detected board info:{'protVer': 3, 'cfgFlags': 0, 'dataBusWdt': 1, 'globVerMajor': 2, 'globVerMinor': 0, 'cmdBuffSize': 60, 'recBuffSize': 512, 'recTimeBase': 16384, 'descr': [83, 51, 50, 120, 120, 32, 70, 114, 101, 101, 77, 65, 83, 84, 69, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0]}
for param=`GetDetectedBoardInfo` work fine.
but...
data = await SendRequest(ws, 'GetConfigParamString', "VS", 20)
print('Application version: ' + data)
---------------------------------------------------------------------------Exception Traceback (most recent call last)Cell In[11], line 1----> 1 data = await SendRequest(ws, 'GetConfigParamString', "VS", 20)2 print('Application version: ' + data)Cell In[5], line 9, in SendRequest(ws, method, *args)7 return response.result['data']8 else:----> 9 raise Exception(response.result['error'])10 else:11 raise Exception(response.message)Exception: {'code': 2147483923, 'message': 'This feature is only available on devices supporting protocol v4 and later.'}Query application name.Note: this API endpoint was added in protocol version 4. For older versions use GetDetectedBoardInfo.
解決済! 解決策の投稿を見る。
Hi @CY9,
I was able to reproduce your issue - it was related to the variable definition:
var variable = {
'name': 'adcMeanValue',
'addr': 'adcMeanValue', <-- this is a symbol name
'type': 'uint',
'size': 4
}
FreeMASTER Lite fails to resolve 'adcMeanValue' to an actual address because there is no symbolic information loaded. Eventually it fails due to type mismatch - read operation expects a numeric number but is receives a string (we will fix this behavior in next release).
To fix this issue you have the following options:
FMSTR_TSA_TABLE_BEGIN(my_tsa_table)
FMSTR_TSA_RW_VAR(adcMeanValue, FMSTR_TSA_UINT32)
FMSTR_TSA_TABLE_END()
FMSTR_TSA_TABLE_LIST_BEGIN()
FMSTR_TSA_TABLE(my_tsa_table)
FMSTR_TSA_TABLE_LIST_END()
and enable TSA feature in freemaster_cfg.h
#define FMSTR_USE_TSA 1 // Enable TSA functionality
After this the call to 'ReadTSA' from Jupyter notebook should return 1 symbol.
var count = 0;
SendRequest(jrpc, 'ReadELF', ['path to the elf file']).then(data => {
console.log('Parsed TSA contained ' + data.count + ' symbols.');
count = parseInt(data.count);
});
Note: after either of the above functions you should be able to find `adcMeanValue` among parsed symbols:
for (var i = 0; i < count; ++i) {
SendRequest(jrpc, 'EnumSymbols', [i]).then(data => console.log(data));
}
var variable = {
'name': 'adcMeanValue',
'addr': 0x2000abcd, // this value can be found in the .map file produced by the compiler
'type': 'uint',
'size': 4
}
SendRequest(jrpc, 'DefineVariable', [variable])
.then(() => console.log('Variable defined successfully.'))
.catch(err => console.error(err.message));
Regarding the the socket connection - due to asynchronous nature of the communication you need to wait for the socket to connect before sending FreeMASTER commands.
Hope it helps,
Iulian
Hi @CY9,
FreeMASTER Lite includes separate examples for Python and NodeJS. Note that, functionality-wise, they are identical.
The one you are referring to does use JavaScript as programming language. For Python, please refer to the Jupyter notebook from `scripting examples\Python` directory.
JavaScript kernel - if you ran the `npm install` command as specified in README IJavascript should have been already installed on your workstation. (we will add these details in the README).
Protocol version error - 'protVer': 3, means that FreeMASTER Driver running on MCU is using protocol version 3 (which is currently the latest one available for S32K1). It does not mean that there are any issues with your application. It means that some new functions introduced in protocol version 4 will not be available - core FreeMASTER functionality is there so you can still monitor & control the embedded application. Additionally, FreeMASTER (desktop tool) is fully backward compatible with older version of the protocol running on the MCU.
Hope it helps,
Iulian
> fully backward compatible with older version of the protocol
?
But, if I didn't remark all `GetConfigParamString` related code :
The Jupyter will not executed aby more !!
Backward compatibility means that newer version of the tool supports older API interfaces or converts the API call to an older format if there is a compatible function.
In case the new additions to the API that have no compatible functions in the old API a corresponding error is returned.
We added notes to the affected Jupyter cells:
Note: this API endpoint was added in protocol version 4. For older versions use GetDetectedBoardInfo
.
Dear iulian_stan,
(base) C:\Users\%UserNAme%\Documents\FreeMASTER Lite\scripting examples\NodeJS> npm i
> freemaster-jsonrpc-api@1.0.0 postinstall
> npm i -g ijavascript && ijsinstall
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN cleanup Failed to remove some directories [
npm WARN cleanup [
npm WARN cleanup 'C:\\ProgramData\\anaconda3\\node_modules\\.ijavascript-P4cT8Jzn',
npm WARN cleanup [Error: EPERM: operation not permitted, unlink 'C:\ProgramData\anaconda3\node_modules\.ijavascript-P4cT8Jzn\node_modules\zeromq\prebuilds\win32-x64\node.abi108.node'] {
npm WARN cleanup errno: -4048,
npm WARN cleanup code: 'EPERM',
npm WARN cleanup syscall: 'unlink',
npm WARN cleanup path: 'C:\\ProgramData\\anaconda3\\node_modules\\.ijavascript-P4cT8Jzn\\node_modules\\zeromq\\prebuilds\\win32-x64\\node.abi108.node'
npm WARN cleanup }
npm WARN cleanup ]
npm WARN cleanup ]
changed 8 packages in 1s
up to date, audited 4 packages in 7s
1 package is looking for funding
run `npm fund` for details
found 0 vulnerabilities
(base) C:\Users\%UserName%\Documents\FreeMASTER Lite\scripting examples\NodeJS>npm fund
freemaster-jsonrpc-api@1.0.0
`-- https://github.com/sponsors/broofa
`-- uuid@10.0.0
After running `jupyter notebook` :
SendRequest(jrpc,'StopComm')
.then(() => console.log('Communication stopped'))
.catch(err => console.error(err.message));
Promise { <pending> }Parsed TSA contained 0 symbols. Variable defined successfully. { name: 'adcMeanValue', addr: 'adcMeanValue', type: 'uint', size: 4, alias: 'adcMeanValue', baseType: { size: 4, indirection: 1, alignment: 4, name: 'uint32' } } { code: -32603, message: 'Internal error. Internal JSON-RPC error.', data: 'writeUInt64: no digits we found in input String' } { code: -32603, message: 'Internal error. Internal JSON-RPC error.', data: 'writeUInt64: no digits we found in input String' } { code: -32603, message: 'Internal error. Internal JSON-RPC error.', data: 'writeUInt64: no digits we found in input String' } Communication stopped
but I can NOT find anything define `writeUInt64` in the NodeJS code ?
Hi @CY9,
From the provided output I can assume the you perform the following:
SendRequest(jrpc, 'WriteVariable', ['adcMeanValue', 100])
.then(data => console.log(data))
.catch(err => console.error(err.message));
Where :
'adcMeanValue' is the variable defined in the previous step
100 is the value to be written
another options is
SendRequest(jrpc, 'WriteUIntVariable', [0x200004cc, 4, 100])
.then(data => console.log(data))
.catch(err => console.error(err.message));
Where Could you share the code that produced the
data: 'writeUInt64: no digits we found in input String'
error so I can better understand the issue ?
Dear iulian_stan,
Please reference attachment
The strange thing is that readyState is NOT CONNECTED(OPEN), but CONNECTING.
WebSocket is not open: readyState 0 (CONNECTING)
Should it delay/wait until the `readyState` is OPEN ?
Hi @CY9,
I was able to reproduce your issue - it was related to the variable definition:
var variable = {
'name': 'adcMeanValue',
'addr': 'adcMeanValue', <-- this is a symbol name
'type': 'uint',
'size': 4
}
FreeMASTER Lite fails to resolve 'adcMeanValue' to an actual address because there is no symbolic information loaded. Eventually it fails due to type mismatch - read operation expects a numeric number but is receives a string (we will fix this behavior in next release).
To fix this issue you have the following options:
FMSTR_TSA_TABLE_BEGIN(my_tsa_table)
FMSTR_TSA_RW_VAR(adcMeanValue, FMSTR_TSA_UINT32)
FMSTR_TSA_TABLE_END()
FMSTR_TSA_TABLE_LIST_BEGIN()
FMSTR_TSA_TABLE(my_tsa_table)
FMSTR_TSA_TABLE_LIST_END()
and enable TSA feature in freemaster_cfg.h
#define FMSTR_USE_TSA 1 // Enable TSA functionality
After this the call to 'ReadTSA' from Jupyter notebook should return 1 symbol.
var count = 0;
SendRequest(jrpc, 'ReadELF', ['path to the elf file']).then(data => {
console.log('Parsed TSA contained ' + data.count + ' symbols.');
count = parseInt(data.count);
});
Note: after either of the above functions you should be able to find `adcMeanValue` among parsed symbols:
for (var i = 0; i < count; ++i) {
SendRequest(jrpc, 'EnumSymbols', [i]).then(data => console.log(data));
}
var variable = {
'name': 'adcMeanValue',
'addr': 0x2000abcd, // this value can be found in the .map file produced by the compiler
'type': 'uint',
'size': 4
}
SendRequest(jrpc, 'DefineVariable', [variable])
.then(() => console.log('Variable defined successfully.'))
.catch(err => console.error(err.message));
Regarding the the socket connection - due to asynchronous nature of the communication you need to wait for the socket to connect before sending FreeMASTER commands.
Hope it helps,
Iulian