Hello

> (write command which fails quietly)
>   result = send_rpc_katcl(l, 5000, KATCP_FLAG_FIRST | 
> KATCP_FLAG_STRING,"?write", KATCP_FLAG_STRING, regName, KATCP_FLAG_STRING, 
> "0", KATCP_FLAG_LAST|KATCP_FLAG_ULONG, 0,NULL);

So this usage isn't quite correct. A "?write" request expects 3 parameters,
a name (which you have and looks correct), and offset (which you have
at 0, also ok), and then *binary* data - what you happened to send is
a text integer which will be interpreted as the binary string ascii
"0". Not only isn't that all zeros, it also is only one byte wide,
while  roach registers are generally 32 bits wide.

So there are two ways of solving this: Use the "?wordwrite" command
which accepts a hex integer as third parameter which is written as
32bits, or write out binary data, using "?write" and a binary buffer,
with a length parameter.

Here is an example of how wordwrite could work. Note that for
wordwrites, the offsets are in multiples of words.

result = send_rpc_katcl(l, 5000, KATCP_FLAG_FIRST | KATCP_FLAG_STRING,
"?wordwrite", KATCP_FLAG_STRING, "sys_scratchpad", KATCP_FLAG_STRING,
"0", KATCP_FLAG_LAST | KATCP_FLAG_XLONG, 0, NULL);

Also in case of failure the result of send_rpc_katcl should be
nonzero, in particular *greater* than zero if the katcp request failed
on the remote side (which it has in your case), and *less* than zero
for local or internal errors.

In case you wish to diagnose problems like that in future, you can
telnet to a roach while you are running your C program. On that
separate connection you can increase the log verbosity to help you see
where your code is failing - to do that issue a "?log-level trace" on
the interactive connection. When I run your code I see

#client-connected 192.168.64.1:58345
#log warn 1354095081805 raw
start\_0\_and\_length\_1\_have\_to\_be\_word\_aligned
#log trace 1354095081805 raw writing\_1\_bytes\_to\_sys_scratchpad
#log error 1354095081806 raw write\_on\_sys_scratchpad\_returns\_zero
#log debug 1354095081806 raw wrote\_-1/1\_bytes\_to\_sys_scratchpad\_at\_0
#log error 1354095081806 raw write\_failed\_-1\_instead\_of\_1\_bytes

Hope that helps

marc

Reply via email to