I think where you call s7_read, you want to wrap that in a catch, probably using s7_call_with_catch. There are examples of it in ffitest.c. The only tricky part (I hope) is passing the "port" argument into the thing called by the catch -- the catch "body" function takes no arguments, as in scheme.