<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>USB 2.0 has a built-in hardware latency. If you are unwilling to go through the trouble of special coding, be sure to use the USB Dongles alone on their own PCI USB Card, this will minimize latency.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hardware may be forced to respond at will if Assembly Code is used to exercise the interfaces, utilizing acquisition calls controlled by processor interrupts. A Real Time Clock (RTC) in internal Hardware or an external RTC can be used to  trigger Processor Interrupts initiating any function in the (Assembly) code and attached hardware.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Using a patch will not work with any reasonable accuracy, depending on the Hardware, (an educated guess) of a many microseconds. Patching indicates high level control (high level language like C++, Python, etc), only low level control will call the hardware anywhere near the timing desired. If you are to access two different devices, their data should be both buffered together in parallel through a first-in-first-out buffer, perhaps even with the RTC time stamp to quantize the packets therefore allowing subsequent coherence in post processing. In high speed audio and video interfaces, very high speed is used, like Firewire and Thunderbolt to stream the data into memory, eliminating most of the hardware latency you are experiencing. The maximum acquisition rate for USB 2.0 is about 48,000 samples per second, times 24 bit depth, times 8, and that is for a fast computer doing nothing else but recording the data stream.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> osmocom-sdr-bounces@lists.osmocom.org [mailto:osmocom-sdr-bounces@lists.osmocom.org] <b>On Behalf Of </b>Michel Pelletier<br><b>Sent:</b> Sunday, November 10, 2013 11:14 PM<br><b>To:</b> osmocom-sdr@lists.osmocom.org<br><b>Subject:</b> multiple devices in one process?<o:p></o:p></span></p></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>I've been thought-experimenting with capturing data from two devices and  measuring their correlation.  For example, if two rtl-sdr processes are launched to read one sample block from two devices, how closely do the two devices' samples line up with each other in time? <br><br>I'm expecting that there will be no reliable correlation.  My working theory is that each process calls into libusb_handle_events_timeout according to its own process schedule and that there is no way to coordinate these two calls to happen closely enough in time for the transfers to happen in a more synchronized fashion.  Threads do not appear to be any better solution to the problem.  I'm not an expert in usb transfers, or libusb, or rtlsdr for that matter, so I'm going only on what I can glean from reading the source code of librtlsdr.c and libusb documentation.<br><br>libusb does say however that it can specifically handle multiple devices in one async loop.  Multiple bulk transfers can be set up to multiple devices in one process, and one call to libusb_handle_events_* can be used to handle those transfers.  My thinking is that because the triggering event for both samples is now the same function call in the same process, the samples will be more synchronized, ideally down to some reliably offset of say a few microseconds. Juha Vierinen's hard-hack to make two devices use a coherent sample clock makes this idea even more interesting to me.<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>But, it doesn't look like librtlsdr can handle multiple devices.  I'm game to take a stab at a patch that can extend its functionality.  But I wanted to run this idea by the community first before spending code time on figuring this out.  Do the experts here think that there is any potential benefit to be gained by taking this approach?<o:p></o:p></p></div></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>-Michel<o:p></o:p></p></div></div><div class=MsoNormal align=center style='text-align:center'><hr size=1 width="100%" noshade style='color:#A0A0A0' align=center></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>No virus found in this message.<br>Checked by AVG - <a href="http://www.avg.com">www.avg.com</a><br>Version: 2013.0.3426 / Virus Database: 3222/6830 - Release Date: 11/12/13<o:p></o:p></p></div></body></html>