CAPL script to update engine rpm on display ECU - can-bus

I have written code in CAPL script to update engine speed.
variable
{
message EEC1_01 mymsg;
msTimer t_mymsg;
}
on start
{
myMsg.byte(3)=0x60;
myMsg.byte(4)=0x22;
setTimerCyclic(mymsg,50);
}
on timer t_mymsg
{
output (myMsg);
}
I am able to see that frame in being transmitted over CAN bus after each 50 sec but that EngineRPM value is not being updated on connected display.
And when I am sending the same frame from IG block value is being updated on Display.

Related

is there a way to modify the CANoe Rx Messages before Receiving on the Bus?

I'm Receiving CAN Message from my Controller(Suppose Message ID= 0x100 signals S1,S2),
But I want to change the signals of Canoe Rx message before Receiving it on the Bus.
basically if you want to change something in a CAN frame you can do something like this in capl.
Example:
Framename: TEMP
Signal you want to change: S1, S2
on message TEMP /* or "on message 0x100" in your case */
{
/* if you have a dbc or arxml assigned to the canoe project you can directly
* use frame names and signal names to manipulate the data.
* if not you need to use it's ID and write over the bytes on it.
*/
this.S1 = whatever_value;
this.S2 = whatever_value;
output(this);
}
If you don't have a DBC/ARXML file added to the project, but i highly recommend to do so. The only thing you need to change in the above code that you have to specify which bytes you overwrite.
You change this:
this.S1 = whatever_value;
this.S2 = whatever_value;
To this:
this.byte(0) = whatever_value;
this.byte(1) = whatever_value;
But you need to know which bytes you need to overwrite.
If you cannot modify the message before being sent by the Controller, your only option to modify your message is a HIL (Hardware In the Loop), which you position between the sender (Controller) and CANoe VNs on the bus.
They are called CANStress modules for instance, if you wish to stick to Vector products.
They will sniff the messages on your bus, and at the defined trigger (by you) will overwrite the Physical Layer with whatever you wish, successfully altering or fault-injecting the bus.
Be aware, that modifying the signals means you have to know their mapping, also how to recalculate the CRC tag and modify that also, otherwise the CANoe VN will not accept your message, and will report Rx_Err CRC Check.

PHP variable reverts back to last assigned after intensive curl operation

I'm querying one api and sending data to another. I'm also querying a mysql database. And doing all this about 40 times in one second. Then waiting a minute and repeating. I have a feeling I'm at the limit of what PHP can do.
My question is about two variables that will randomly revert back to their last value, from the previous loop. They only change their value after the call to self::apiCall() (below in the second function). Both $product and $productId will randomly change their value, about once every 40 loops or so.
I boosted PHP to 7.2, increased memory to 512, and assigned some variables to null to save memory. I'm not getting any official memory warnings, but watching the variables randomly go back to their last value is perplexing. Here's what the code looks like.
/**
* The initial create products loop which calls the secondary function where
* the variables can change.
**/
public static function createProducts() {
// Create connection
$conn = new mysqli(SERVERNAME, USERNAME, PASSWORD, DBNAME, PORT);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// This will go through each row and echo the id column
$productResults = mysqli_query($conn, "SELECT * FROM product_creation_queue");
if(mysqli_num_rows($productResults) > 0) {
$rowIndex = 0;
while($row = mysqli_fetch_assoc($productResults)){
self::createProduct($conn, $product);
}
}
}
/**
* The second function where I see both $product and $productId changing
* from time to time, which completely breaks the code. Their values
* only change after the call to self::createProduct() which is simply a
* curl function to hit an api endpoint.
**/
public static function createProduct($mysqlConnection, $product) {
// convert back to array from json
$productArray = json_decode($product, TRUE);
// here the value of $productId is one thing
$productId = $productArray['product']['id'];
// here is the curl call
$addProduct = self::api_call(TOKEN, SHOP, ENDPOINT, $product, 'POST');
// and randomly here it can revert to it's last value in a previous loop
echo $productId;
}
The problem was that the entire 40-query procedure took more than one minute to complete. And the cron job that started the procedure on the minute would start the next one before the first one had completed, thereby somehow re-assigning variables on the fly. The queries usually took less than one minute, but when it was longer, the conflicts appeared, thus leading to the appearance of randomness.
I reduced the number of queries per minute so now the process completes in less than 60 seconds and no variables are ever overwritten. I still don't understand how the variables would change if two php processes are happening at the same time--it seems like they would be siloed.

limitation for NumberOfElements in scatter/gather list

My device driver for a PCIe FPGA is based on 7600.16385.1\src\general\PLX9x5x
Upon ReadFile in the application, PLxEvtIoRead is called:
//
// Initialize this new DmaTransaction.
//
status = WdfDmaTransactionInitializeUsingRequest(
devExt->ReadDmaTransaction,
Request,
PLxEvtProgramReadDma,
WdfDmaDirectionReadFromDevice );
//
// Execute this DmaTransaction.
//
status = WdfDmaTransactionExecute( devExt->ReadDmaTransaction,
WDF_NO_CONTEXT);
....
Upon calling to WdfDmaTransactionExecute, PLxEvtProgramReadDma is called.
BOOLEAN
PLxEvtProgramReadDma(
IN WDFDMATRANSACTION Transaction,
IN WDFDEVICE Device,
IN WDFCONTEXT Context,
IN WDF_DMA_DIRECTION Direction,
IN PSCATTER_GATHER_LIST SgList
)
{
KdPrint ((???SgList->NumberOfElements = %d\n???,SgList->NumberOfElements));
}
The problem:
i want to transfer a large amount of data via this Scatter/Gather list(around 1 GB), but it seems NumberOfElements is limited by something, somehow that the larges transmition is 1MB(255 element in list, each 4k). i changed MaximumTransfecrLength in function below to 500MB:
WDF_DMA_ENABLER_CONFIG_INIT(&dmaConfig,
WdfDmaProfileScatterGatherDuplex,
deviceContext->MaximumTransferLength);
but still i can not transfer more than 1MB.
what is the thing that limits NumberOfElements and how i can solve it?
I needed to change the second parameter in WDF_DMA_ENABLER_CONFIG_INIT function to WdfDmaProfileScatterGather64, and of course we have to make sure that hardware(FPGA or anything in other side of PCIE endpoint) can support 64-bit addressing mode.
I just change my code as below:
WDF_DMA_ENABLER_CONFIG_INIT(&dmaConfig,
WdfDmaProfileScatterGather64,
deviceContext->MaximumTransferLength);

JMeter - fail a test based on the average response time

I am running a JMeter job in Jenkins using performance plugin. I need to fail a job if the average response time < 3 seconds. I see the "duration assertion" in jmeter, but that works on each thread (each http request). Instead is it possible to do the duration assertion on average for each page?
This is the way I tried adding the BeanSehll Listener and Assertion.
Recording Controller
**Home Page**
BeanShell Listener
Debug Sampler
**Page1**
BeanShell Listener
Debug Sampler
Beanshell Assertion
View Results Tree
You can implement this check via some form of Beanshell scripting
Add a Beanshell Listener at the same level as all your requests live
Put the following code into Beanshell Listener's "Script" area
String requests = vars.get("requests");
String times = vars.get("times");
long requestsSum = 0;
long timesSum = 0;
if (requests != null && times != null) {
log.info("requests: " + requests);
requestsSum = Long.parseLong(vars.get("requests"));
timesSum = Long.parseLong(vars.get("times"));
}
long thisRequest = sampleResult.getTime();
timesSum += thisRequest;
requestsSum++;
vars.put("requests", String.valueOf(requestsSum));
vars.put("times", String.valueOf(timesSum));
long average = timesSum / requestsSum;
if (average > 3000){
sampleResult.setSuccessful(false);
sampleResult.setResponseMessage("Average response time is greater than threshold");
}
The code above will record sums of response times for each request and total number of requests into times and requests JMeter Variables
See How to use BeanShell: JMeter's favorite built-in component guide for comprehensive information on Beanshell scripting in Apache JMeter.
Based on the other answer, I managed to create something that works while using multiple threads.
Add the following code as a script to your JSR223 listener, you can also save it to file and load it from file (for easy reuse). I used a parameter in seconds to set the duration threshold.
import org.apache.jmeter.util.JMeterUtils;
int totalRequests = Integer.parseInt(ctx.getThreadGroup().getSamplerController().getProperty("LoopController.loops").getStringValue()) * ctx.getThreadGroup().getNumThreads();
long requestsCount = JMeterUtils.getPropDefault("requestsCount"+sampleResult.toString(),0);
long timesSum = JMeterUtils.getPropDefault("times"+sampleResult.toString(),0);
long thisRequestTime = sampleResult.getTime();
timesSum += thisRequestTime;
requestsCount++;
JMeterUtils.setProperty("requestsCount"+sampleResult.toString(), String.valueOf(requestsCount));
JMeterUtils.setProperty("times"+sampleResult.toString(), String.valueOf(timesSum));
long average = timesSum / requestsCount;
long threshold = Integer.parseInt(args[0])*1000;
if (requestsCount >= totalRequests) {
if(average > threshold){
sampleResult.setSuccessful(false);
sampleResult.setResponseMessage("Average response time is greater than threshold, average: " + String.valueOf(average) + ", threshold: " + threshold);
}
log.info("Average response time (" + sampleResult.toString() + "): " + String.valueOf(average) + ", threshold: " + threshold);
}
This stores it in the global properties, that are saved for the full JVM run. To keep consistency in between runs, I added a setup thread group with a JSR223 sampler, with this code:
import org.apache.jmeter.util.JMeterUtils;
JMeterUtils.getJMeterProperties().clear();
log.info("cleared properties");

Mysterious output from Lua after modifying a control

I am using Lua with wxLua to build a GUI. Normally when I exit the app, I get no output from Lua.
However I just added a function to a wxListView (called myListView) like this
myListView.foo = bar
function bar (self)
-- do something with the wxListView
end
Whether or not I ever called foo(), when I exit the app, I get the following output from Lua:
~wxLuaObject -2 1 0
If I comment out the assignment, I get no output when exiting the app. If instead, I nil out foo later on in the code:
myListView.foo = nil
I get the same output immediately when that line is executed and then again on program exit.
What does the output mean? What am I doing wrong? How do I fix it?
Thanks!
This seems to be an internal diagnostic for the case when wxLuaObject is destroyed and m_reference == LUA_NOREF (-2 as it is in your case) and Lua state object is not in closing state (0 as reported in your case):
// this is from modules/wxlua/src/wxlbind.cpp (starts on line 83 in my version)
wxLuaObject::~wxLuaObject()
{
if ((m_reference != LUA_NOREF) && m_wxlState->Ok() && !m_wxlState->IsClosing())
{
m_wxlState->wxluaR_Unref(m_reference, &wxlua_lreg_refs_key);
m_reference = LUA_NOREF;
}
//else if (!m_wxlState->IsClosing())
// wxPrintf(wxT("~wxLuaObject %d %d %d\n"), (int)m_reference, (int)m_wxlState->Ok(), (int)m_wxlState->IsClosing());
I have this message commented out in my wxlua code (2.8.12.1), but you may want to check your version and upgrade as needed. This is the only place where ~wxLuaObject message appears in the source code. It seems to be harmless, but it can potentially point to other issues with what you are doing.

Resources