I want to convert a program that simulates CAN nodes using python CAN into a CANoe simulation using CAPL. In the python sim I used numpy for math functions. How can I import statistical math functions such as standard deviation or normal.cdf into my CAPL script?
CANoe allows you to use custom DLLs in your CAPL code (search CANoe Help for CAPL-DLL).
So, if you can re-write your Python code to work with Cython (reference: http://docs.cython.org/src/userguide/numpy_tutorial.html), you can try to create a DLL from your new Cython code and then call the exported functions of that DLL from your CAPL script.
Related
Here you can fetch word frequencies from Wolfram but I would like to know how to do this in Python because I am having difficulty finding any code to do this.
https://reference.wolfram.com/language/ref/WordFrequencyData.html
If you have access to Wolfram Engine/Cloud, you can use the Wolfram Client Library for Python to evaluate an expression using Wolfam's WordFrequencyData function in Python.
I want to implement a hashing algorithm like md5 in CAPL (CANoe). Is there any built-in hashing function in CAPL?
I would suggest to create a CAPL Dll which implements your hash-algorithm in C++ and include it via #pragma library() in your code.
There is an example in "CANoe Sample Configurations\Programming\CAPLdll". For more infos take a look at the chapter "CAPL DLL" in your CANoe help.
There is not a built in hash function in CAPL, the closest I've been able to find is a checksum calculation function. (J1939CalcChecksum) Anyhow you can use the CANoe .NET API, once you are using .NET you can call its hashing libraries.
The reference for CANoe .NET API is in Vector's page in the provided link.
I would like to write a Cython function that involves strings, so of course I am inclined to use libcpp.string. But I could not figure out how to import std functions like std::to_string().
What is the cleanest way to make std functions available to my Cython file?
A wrapper needs to be written. A full tutorial can be found on docs.cython.org. Some of the standard library has already been ported, but given the monumental effort needed to complete a task (and then do C++11), I highly doubt you'll see std::to_string any time soon.
Anyways, just write it yourself. std::to_string is just a wrapper over std::sprintf anyway.
I'd like to load a MATLAB file that stores a 1x1 struct with 4 fields using Go. I haven't found anything comparable to Python's SciPy which has a "loadmat" function. What is the best way to read .mat files in Go?
You may have to write your own Go package. MathWorks suggests that you interface with their MATLAB MAT-file C API. To do that in Go, use cgo.
References:
MATLAB MAT-File Format - MathWorks
Command cgo
C? Go? Cgo!
No, there doesn't seem to be any project for reading MalLab files in pure Go (in CGo, see PeterSO's answer):
go-search doesn't list any relevant project
GitHub doesn't have any either.
the Libraries list doesn't include any
And, there were performance consideration as well, mentioned in "Go matrix library".
The discussion was more about calling go from Matlab.
I've been looking recently into creating a new native language. I understand the (very) basics of the PE format and I've grabbed an assembler with a fairly kind interface off the webs, which I've successfully used to implement some simple functions. But I've run into a problem using functions from a library. The only way that I've called library functions from a dynamically compiled function previously is to pass in the function pointer manually- something I can't do if I create PE files and execute them in their own process. Now, I'm not planning on using the CRT, but I will need access to the Win API to implement my own standard libraries. How do I generate a reference to a WinAPI function so that the PE loader will patch it up?
You need to write an import table. It's basically a list of function names that you wish to use in your application. It's pointed to by the PE header. The loader loads the DLL files into the process memory space for you, finds the requested function in their export table and leaves the address for it in the import table. You then usually dereference that and jmp there.
Check out Izelion's assembly tutorial for the full details and for asm examples.
How about starting by emitting C instead of assembly? Then writing directly to ASM is just an optimization.
I'm not being facetious: most compilers turn out some kind of intermediate code before the final native code pass.
I realize you're trying to get away from all the null-delmited rigmarole, but you'll need that for the WinAPI functions anyway.
Re-reading your question: you do realize that you can get the WinAPI function addresses by calling LoadLibrary(), then calling GetProcAddress(), and then setting up the call...right?
If you want to see how to bootstrap this from pure assembly: the old SDKs had ASM sample code, probably the new ones still do. If they don't, the DDK will.