<div dir="ltr"><div class="gmail_extra"><div class="gmail_extra">Hello Jef,</div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks for making time to let us know what you </div><div class="gmail_extra">have in mind for the next release. More or less it is </div><div class="gmail_extra">similar with the changes I made, except that I tried </div><div class="gmail_extra">to avoid to modify the native serial implementation.</div><div class="gmail_extra"><br></div><div class="gmail_extra">I will make you a short resume about the changes </div><div class="gmail_extra">I did because I believe that there were too many </div><div class="gmail_extra">posts and it is not easy to keep the track.</div><div class="gmail_extra"><br></div><div class="gmail_extra">The dc_serial_t structure is declared as:</div><div class="gmail_extra">struct dc_serial_t {</div><div class="gmail_extra"><span class="" style="white-space:pre">        </span>serial_t *port;<span class="" style="white-space:pre">                   </span>//serial device port</div><div class="gmail_extra"><span class="" style="white-space:pre"> </span>dc_transport_t type;<span class="" style="white-space:pre">              </span>//the type of the transport (USB, SERIAL, IRDA, BLUETOOTH)</div><div class="gmail_extra"><span class="" style="white-space:pre">   </span>void *data;<span class="" style="white-space:pre">                               </span>//specific data for serial device</div><div class="gmail_extra"><span class="" style="white-space:pre">    </span>const dc_serial_operations_t *ops;<span class="" style="white-space:pre">        </span>//reference to a custom set of operations</div><div class="gmail_extra">} dc_serial_t;</div><div class="gmail_extra"><br></div><div class="gmail_extra">As you can see, the only difference is that I </div><div class="gmail_extra">added a new member (dc_transport_type). </div><div class="gmail_extra">I thought that this can be used to identify the </div><div class="gmail_extra">type of the transport and to do some specific</div><div class="gmail_extra">operations if they are needed.</div><div class="gmail_extra">Also I used a pointer member for serial_t.</div><div class="gmail_extra">Dirk suggested to remove the pointer but</div><div class="gmail_extra">it was easier for me to use it :).</div><div class="gmail_extra"><br></div><div class="gmail_extra">I choose to represent all functions which are </div><div class="gmail_extra">used for the communication and may need </div><div class="gmail_extra">a custom implementation, depending on the </div><div class="gmail_extra">protocol used (Bluetooth, IRDA, etc).</div><div class="gmail_extra"><br></div><div class="gmail_extra">The dc_serial_operations_t is:</div><div class="gmail_extra">struct dc_serial_operations_t</div><div class="gmail_extra">{</div><div class="gmail_extra"><span class="" style="white-space:pre">     </span>int (*open) (serial_t **device, dc_context_t *context, const char *name);</div><div class="gmail_extra"><span class="" style="white-space:pre">    </span>int (*close) (serial_t *device);</div><div class="gmail_extra"><span class="" style="white-space:pre">     </span>int (*read) (serial_t *device, void* data, unsigned int size);</div><div class="gmail_extra"><span class="" style="white-space:pre">       </span>int (*write) (serial_t *device, const void* data, unsigned int size);</div><div class="gmail_extra"><span class="" style="white-space:pre">        </span>int (*flush) (serial_t *device, int queue);</div><div class="gmail_extra"><span class="" style="white-space:pre">  </span>int (*get_received) (serial_t *device);</div><div class="gmail_extra"><span class="" style="white-space:pre">      </span>int (*get_transmitted) (serial_t *device);</div><div class="gmail_extra">} dc_serial_operations_t;</div><div class="gmail_extra"><br></div><div class="gmail_extra">As I said, I tried to avoid modifications on </div><div class="gmail_extra">native serial implementation. Therefore I used </div><div class="gmail_extra">the same signatures for needed functions.</div><div class="gmail_extra"><br></div><div class="gmail_extra">I preferred to do that because I wanted to keep </div><div class="gmail_extra">backwards compatibility and to do as few changes </div><div class="gmail_extra">as possible. So I created a dc_device_custom_open </div><div class="gmail_extra">method where the application  can pass a reference </div><div class="gmail_extra">to a dc_serial_t structure.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Also I added a dc_serial_native_open which </div><div class="gmail_extra">creates a dc_serial_t structure for the </div><div class="gmail_extra">native serial implementation. In this way I could </div><div class="gmail_extra">use it in the DEVICE_FAMILY_device_open</div><div class="gmail_extra">method and maintain the backwards compatibility.</div><div class="gmail_extra"><br></div><div class="gmail_extra">It is obvious that you have a clear idea about </div><div class="gmail_extra">how the libdivecomputer API should look</div><div class="gmail_extra">like and which are the things that need to be </div><div class="gmail_extra">refactored/cleaned.</div><div class="gmail_extra"><br></div><div class="gmail_extra">I would definitely like to help you (now or later).</div><div class="gmail_extra"><br></div><div class="gmail_extra">Dirk, Thiago, do you think that I should refactor </div><div class="gmail_extra">again the libdivecomputer? Should I change</div><div class="gmail_extra">again the design? Or I should continue my current </div><div class="gmail_extra">work, use the current design for all vendors</div><div class="gmail_extra">which have Bluetooth support, implement the </div><div class="gmail_extra">Bluetooth transfer on Windows platforms and finally</div><div class="gmail_extra">start to modify the design as Jef suggested?</div><div class="gmail_extra"><br></div><div class="gmail_extra">I ask this because in the end the Subsurface </div><div class="gmail_extra">custom serial implementation doesn't need </div><div class="gmail_extra">many changes to be integrated with a new </div><div class="gmail_extra">version of libdivecomputer and with its design.</div><div class="gmail_extra">Also, I already have a functional prototype.</div><div class="gmail_extra"><br></div><div class="gmail_extra">I am not sure how to prioritize things. :)</div><div class="gmail_extra"><br></div><div class="gmail_extra">So please let me know what you think.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks,</div><div class="gmail_extra">Claudiu</div></div></div>