Batch 28 commit b7fd210 gave ESP NVS iterator versions and RT-Thread workqueue timer state as HARD: all 3 attempts of each ran out of model context, which counts as a failure. Each task comes from the commit Qwen measured, its digest matches, and it is still present at the batch branch head. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
114 lines
5.8 KiB
C
114 lines
5.8 KiB
C
/* SPDX-License-Identifier: Apache-2.0
|
|
* Raw API observation driver. Input commands specify operations; there are no expected results here.
|
|
*/
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <rtdevice.h>
|
|
#include "port.h"
|
|
#define N 16
|
|
struct work_data {int id,action,arg;long value;};
|
|
struct timer_data {int id,action,arg;};
|
|
static struct rt_workqueue *queues[2];
|
|
static struct rt_work works[N];
|
|
static struct work_data wd[N];
|
|
static struct rt_timer timers[N];
|
|
static struct timer_data td[N];
|
|
static int enters;
|
|
static int app_q,app_w,app_delay;
|
|
static void app_entry(void *p) {
|
|
(void)p;
|
|
printf("R %ld\n",(long)rt_workqueue_submit_work(queues[app_q],&works[app_w],app_delay));
|
|
}
|
|
static void enter_hook(rt_timer_t t) {(void)t;enters++;}
|
|
static void work_cb(struct rt_work *w,void *p) {
|
|
struct work_data *d=p;int action=d->action;d->action=0;
|
|
printf("W %d %ld %u\n",d->id,d->value,rt_tick_get());
|
|
if(action==1)printf("R %ld\n",(long)rt_workqueue_submit_work(queues[0],w,d->arg));
|
|
if(action==2)printf("R %ld\n",(long)rt_workqueue_cancel_work(queues[0],w));
|
|
}
|
|
static void timer_cb(void *p) {
|
|
struct timer_data *d=p;rt_tick_t t=(rt_tick_t)d->arg;
|
|
printf("T %d %u\n",d->id,rt_tick_get());
|
|
switch(d->action) {
|
|
case 1:printf("R %ld\n",(long)rt_timer_start(&timers[d->id]));break;
|
|
case 2:
|
|
printf("R %ld\n",(long)rt_timer_control(&timers[d->id],RT_TIMER_CTRL_SET_TIME,&t));
|
|
printf("R %ld\n",(long)rt_timer_start(&timers[d->id]));break;
|
|
case 3:printf("R %ld\n",(long)rt_timer_stop(&timers[d->id]));break;
|
|
case 4:printf("R %ld\n",(long)rt_timer_start(&timers[d->arg]));break;
|
|
case 5:printf("R %ld\n",(long)rt_timer_stop(&timers[d->arg]));break;
|
|
}
|
|
}
|
|
int main(void) {
|
|
char cmd[32];int a,b,c,d,e;long value;
|
|
setvbuf(stdout,NULL,_IONBF,0);
|
|
os_init();rt_system_timer_init();rt_system_timer_thread_init();
|
|
queues[0]=rt_workqueue_create("worker0",8192,4);queues[1]=rt_workqueue_create("worker1",8192,5);
|
|
rt_timer_enter_sethook(enter_hook);os_drain();
|
|
while(scanf("%31s",cmd)==1) {
|
|
if(!strcmp(cmd,"WORK")) {
|
|
if(scanf("%d%ld%d%d",&a,&value,&b,&c)!=4)return 80;
|
|
wd[a]=(struct work_data){a,b,c,value};rt_work_init(&works[a],work_cb,&wd[a]);
|
|
} else if(!strcmp(cmd,"SUB")) {
|
|
if(scanf("%d%d%d",&a,&b,&c)!=3)return 80;
|
|
printf("R %ld\n",(long)rt_workqueue_submit_work(queues[a],&works[b],(rt_tick_t)c));
|
|
} else if(!strcmp(cmd,"RACE")) {
|
|
int cancel_mode;
|
|
if(scanf("%d%d%d%d",&a,&b,&cancel_mode,&c)!=4)return 80;
|
|
printf("O %ld\n",(long)(cancel_mode ? rt_workqueue_cancel_work(queues[a],&works[b]):
|
|
rt_workqueue_submit_work(queues[a],&works[b],(rt_tick_t)c)));
|
|
} else if(!strcmp(cmd,"DO")) {
|
|
if(scanf("%d%d",&a,&b)!=2)return 80;
|
|
printf("R %ld\n",(long)rt_workqueue_dowork(queues[a],&works[b]));
|
|
} else if(!strcmp(cmd,"URGENT")) {
|
|
if(scanf("%d%d",&a,&b)!=2)return 80;
|
|
printf("R %ld\n",(long)rt_workqueue_urgent_work(queues[a],&works[b]));
|
|
} else if(!strcmp(cmd,"CANCEL")) {
|
|
if(scanf("%d%d",&a,&b)!=2)return 80;
|
|
printf("R %ld\n",(long)rt_workqueue_cancel_work(queues[a],&works[b]));
|
|
} else if(!strcmp(cmd,"SYNC")) {
|
|
if(scanf("%d%d",&a,&b)!=2)return 80;
|
|
printf("R %ld\n",(long)rt_workqueue_cancel_work_sync(queues[a],&works[b]));
|
|
} else if(!strcmp(cmd,"ALL")) {
|
|
if(scanf("%d",&a)!=1)return 80;
|
|
printf("R %ld\n",(long)rt_workqueue_cancel_all_work(queues[a]));
|
|
} else if(!strcmp(cmd,"APP")) {
|
|
rt_thread_t thread;
|
|
if(scanf("%d%d%d",&app_q,&app_w,&app_delay)!=3)return 80;
|
|
thread=rt_thread_create("app",app_entry,NULL,8192,6,10);rt_thread_startup(thread);
|
|
} else if(!strcmp(cmd,"STEP")) {
|
|
char name[32];if(scanf("%31s",name)!=1)return 80;os_step(name);
|
|
} else if(!strcmp(cmd,"TIMER")) {
|
|
if(scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&td[15].arg)!=6)return 80;
|
|
td[a]=(struct timer_data){a,e,td[15].arg};
|
|
rt_timer_init(&timers[a],"user",timer_cb,&td[a],b,(c?RT_TIMER_FLAG_SOFT_TIMER:RT_TIMER_FLAG_HARD_TIMER)|(d?RT_TIMER_FLAG_PERIODIC:RT_TIMER_FLAG_ONE_SHOT));
|
|
} else if(!strcmp(cmd,"START")) {
|
|
if(scanf("%d",&a)!=1)return 80;printf("R %ld\n",(long)rt_timer_start(&timers[a]));
|
|
} else if(!strcmp(cmd,"STOP")) {
|
|
if(scanf("%d",&a)!=1)return 80;printf("R %ld\n",(long)rt_timer_stop(&timers[a]));
|
|
} else if(!strcmp(cmd,"SET")) {
|
|
rt_tick_t tick;if(scanf("%d%u",&a,&tick)!=2)return 80;
|
|
printf("R %ld\n",(long)rt_timer_control(&timers[a],RT_TIMER_CTRL_SET_TIME,&tick));
|
|
} else if(!strcmp(cmd,"MODE")) {
|
|
if(scanf("%d%d",&a,&b)!=2)return 80;
|
|
printf("R %ld\n",(long)rt_timer_control(&timers[a],b?RT_TIMER_CTRL_SET_PERIODIC:RT_TIMER_CTRL_SET_ONESHOT,NULL));
|
|
} else if(!strcmp(cmd,"GET")) {
|
|
rt_tick_t tick=0;rt_uint32_t state=0;if(scanf("%d",&a)!=1)return 80;
|
|
rt_timer_control(&timers[a],RT_TIMER_CTRL_GET_TIME,&tick);rt_timer_control(&timers[a],RT_TIMER_CTRL_GET_STATE,&state);
|
|
printf("G %u %d\n",tick,state!=RT_TIMER_FLAG_DEACTIVATED);
|
|
} else if(!strcmp(cmd,"TICK")||!strcmp(cmd,"ADV")) {
|
|
rt_tick_t tick;if(scanf("%u",&tick)!=1)return 80;os_tick(tick);
|
|
if(!strcmp(cmd,"ADV")){rt_timer_check();os_drain();}
|
|
} else if(!strcmp(cmd,"DRAIN"))os_drain();
|
|
else if(!strcmp(cmd,"PROGRESS")) {
|
|
int before=enters,budget=1000,drain;
|
|
if(scanf("%d",&drain)!=1)return 80;
|
|
while(enters==before&&budget--&&os_step("timer")){}
|
|
if(drain)os_drain();
|
|
printf("P %d\n",enters!=before);
|
|
} else return 81;
|
|
}
|
|
return 0;
|
|
}
|