Hi Lucien, Le 20/10/2021 à 18:48, Lucien Anti-Spam a écrit : > Hey Alexis, > I am VERY new to this dev, but I have been digging about because I needed a > VXI based "event" (intr_srq) so I have looked at this code a bit.Here is my > layman read of the code and how the "timeout" value passed is handled. > Normally the sr_scpi_source_add takes an "events" (nearly always G_IO_IN) and > a timeout, and a callback/cb_data.This call makes a call to a "operations" > pointer, scpi->source_add. So this ends up in one of the various SCPI > transport layers * USB > * VXI / VISA (via rpc, or librevisa) * Serial (uart support) * TCP (raw TCP > port; aka SCPI-Raw by Agilent, SOCKET server for Tektronix) * and so on ( > See: https://github.com/droghio/sigrok/blob/master/src/scpi/scpi.c#L423 ) > For most protocols this ends up really just boiling down to being a counter > that then timesout after the passed in "timeout" value mentioned above, which > means you effectively end up polling on the transport layer. For USB its > different, see below. > https://github.com/droghio/sigrok/blob/master/src/scpi/scpi_usbtmc_libusb.c#L416 > SR_PRIV const struct sr_scpi_dev_inst scpi_usbtmc_libusb_dev = { > .. .source_add = scpi_usbtmc_libusb_source_add, > ..}; > static int scpi_usbtmc_libusb_source_add( ... > return usb_source_add(session, uscpi->ctx, timeout, cb, cb_data);... } > > https://github.com/merbanan/libsigrok/blob/master/src/usb.c > > static GSource *usb_source_new ... > upollfds = libusb_get_pollfds(usb_ctx); > > SR_PRIV int usb_source_add( ... > source = usb_source_new(session, ctx->libusb_ctx, timeout); > ... > ret = sr_session_source_add_internal(session, ctx->libusb_ctx, source); > ...} > > So now for usb it seems you would wait on control pipe (fd0) and then timerfd > or async io transfer timeout.( libusb: Polling and timing ). So once some > USB activity happens, or the USB stack times out then you will come back to > the call back. > Cheers, > Luc >
Ok thanks I understand more now. -- Alexis Murzeau PGP: B7E6 0EBB 9293 7B06 BDBC 2787 E7BD 1904 F480 937F |
signature.asc
Description: OpenPGP digital signature
_______________________________________________ sigrok-devel mailing list sigrok-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sigrok-devel