Route D (real fixes in embedded open-source projects) keeps producing the hard tasks: of 64 measured so far, 15 are HARD and 4 MEDIUM, mostly because Qwen exhausts its context in the larger real workspaces. This adds CANopen SRDO and ASCII timing, FreeRTOS DHCP, lwIP MQTT fragments, printf extremal exponents, Zephyr packet buffers and heatshrink (HARD), plus lwjson, RFM9x, SFUD and nanopb proto3 (MEDIUM). From batch 27 (spec-dense implementation tasks) come one HARD and one MEDIUM; that batch is winding down after 30 tasks gave 1 HARD and 3 MEDIUM. Each task comes from the commit Qwen measured, its digest matches, and it is still present at the batch branch head. Agent timeouts stay excluded: a pyserial attempt timed out on Qwen's own blocking read yet graded PASS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
127 lines
3.9 KiB
C
127 lines
3.9 KiB
C
/* SPDX-License-Identifier: Apache-2.0
|
|
* Raw public API observer. All expected packet behavior lives in check.py.
|
|
*/
|
|
#include <zephyr/sys/mpsc_pbuf.h>
|
|
#include <stdlib.h>
|
|
static struct mpsc_pbuf_buffer queue;
|
|
static uint32_t memory[64];
|
|
static union mpsc_pbuf_generic *reserved[4];
|
|
static const union mpsc_pbuf_generic *held;
|
|
static unsigned int scheduled;
|
|
static uint32_t packet_words(const union mpsc_pbuf_generic *p)
|
|
{
|
|
return p->hdr.data & 255U;
|
|
}
|
|
static void observe(const char *event, const union mpsc_pbuf_generic *p)
|
|
{
|
|
printf("%s %u", event, p != NULL);
|
|
if (p) {
|
|
uint32_t n = packet_words(p);
|
|
printf(" %u %u", n, p->hdr.data >> 8);
|
|
const uint32_t *v = (const uint32_t *)p;
|
|
/* Bound the observation itself when a candidate returns a bad header. */
|
|
for (uint32_t i = 1; i < n && i < 64; i++) printf(" %u", v[i]);
|
|
}
|
|
putchar('\n');
|
|
fflush(stdout);
|
|
}
|
|
static void notify_drop(const struct mpsc_pbuf_buffer *b,
|
|
const union mpsc_pbuf_generic *p)
|
|
{
|
|
ARG_UNUSED(b);
|
|
observe("drop", p);
|
|
}
|
|
void host_on_wait(struct k_sem *sem)
|
|
{
|
|
ARG_UNUSED(sem);
|
|
unsigned int action = scheduled;
|
|
scheduled = 0;
|
|
if (action) {
|
|
const union mpsc_pbuf_generic *p = mpsc_pbuf_claim(&queue);
|
|
observe("scheduled", p);
|
|
if (action == 2 && p) {
|
|
mpsc_pbuf_free(&queue, p);
|
|
puts("scheduled_free 1");
|
|
}
|
|
}
|
|
}
|
|
static union mpsc_pbuf_generic *allocate(unsigned int n, unsigned int id, int wait)
|
|
{
|
|
union mpsc_pbuf_generic *p = mpsc_pbuf_alloc(&queue, n, wait);
|
|
printf("alloc %u %u\n", id, p != NULL);
|
|
fflush(stdout);
|
|
if (p) {
|
|
p->hdr.data = (id << 8) | n;
|
|
uint32_t *v = (uint32_t *)p;
|
|
for (unsigned int i = 1; i < n; i++) v[i] = id * 1009U + i * 37U;
|
|
}
|
|
return p;
|
|
}
|
|
int main(void)
|
|
{
|
|
unsigned int size, overwrite, index = 0;
|
|
if (scanf("%u %u", &size, &overwrite) != 2) return 2;
|
|
struct mpsc_pbuf_buffer_config cfg = {
|
|
.buf = memory, .size = size, .get_wlen = packet_words,
|
|
.notify_drop = notify_drop,
|
|
.flags = overwrite ? MPSC_PBUF_MODE_OVERWRITE : 0
|
|
};
|
|
mpsc_pbuf_init(&queue, &cfg);
|
|
char command[8];
|
|
while (scanf("%7s", command) == 1) {
|
|
unsigned int n, id, slot;
|
|
int wait;
|
|
printf("begin %u\n", index++);
|
|
fflush(stdout);
|
|
switch (command[0]) {
|
|
case 'P':
|
|
if (scanf("%u %u %d", &n, &id, &wait) != 3) return 2;
|
|
{
|
|
union mpsc_pbuf_generic *p = allocate(n, id, wait);
|
|
if (p) mpsc_pbuf_commit(&queue, p);
|
|
}
|
|
break;
|
|
case 'A':
|
|
if (scanf("%u %u %u", &slot, &n, &id) != 3) return 2;
|
|
reserved[slot] = allocate(n, id, K_NO_WAIT);
|
|
break;
|
|
case 'C':
|
|
if (scanf("%u", &slot) != 1) return 2;
|
|
printf("commit %u\n", reserved[slot] != NULL);
|
|
if (reserved[slot]) mpsc_pbuf_commit(&queue, reserved[slot]);
|
|
reserved[slot] = NULL;
|
|
break;
|
|
case 'T':
|
|
held = mpsc_pbuf_claim(&queue);
|
|
observe("claim", held);
|
|
break;
|
|
case 'F':
|
|
printf("free %u\n", held != NULL);
|
|
if (held) mpsc_pbuf_free(&queue, held);
|
|
held = NULL;
|
|
break;
|
|
case 'V':
|
|
observe("held", held);
|
|
break;
|
|
case 'E':
|
|
{
|
|
const union mpsc_pbuf_generic *p = mpsc_pbuf_claim(&queue);
|
|
observe("consume", p);
|
|
if (p) mpsc_pbuf_free(&queue, p);
|
|
}
|
|
break;
|
|
case 'S':
|
|
if (scanf("%u", &scheduled) != 1) return 2;
|
|
break;
|
|
case 'Q':
|
|
printf("pending %u\n", mpsc_pbuf_is_pending(&queue));
|
|
break;
|
|
default:
|
|
return 2;
|
|
}
|
|
puts("end");
|
|
fflush(stdout);
|
|
}
|
|
return 0;
|
|
}
|