DC_SERIAL_ITERATOR_NEW(3)
π DC_SERIAL_ITERATOR_NEW(3)
okay so this is a page from the Library Functions Manual (section 3, the "these are functions bestie" section) and it's literally all about spinning up an iterator for your serial devices. it's giving "let me introduce you to your ports" energy π¦
β¨ NAME β¨
dc_serial_iterator_new β create an iterator to enumerate the serial devices π
π LIBRARY π
you'll find this in the library βlibdivecomputerβ. that's the one. that's the girl. π
πΈ SYNOPSIS πΈ
#include <libdivecomputer/serial.h>
dc_status_t
dc_serial_iterator_new(dc_iterator_t **iterator, dc_context_t *context,
dc_descriptor_t *descriptor);
π« DESCRIPTION π«
So what this does is: it iterates through the available serial devices that match the descriptor you gave it. no cap, that's the whole vibe. π
It takes a context opened with dc_context_new(3), and a descriptor that you usually found by searching through dc_descriptor_iterator_new(3). those two are your besties going into this function, fr fr.
On returning DC_STATUS_SUCCESS the iterator gets set to a dc_iterator_t β and that's the thing you use to iterate the available serial devices with dc_iterator_next(3). slay. β¨
The value type of the iterator is of type dc_serial_device_t. and ooh, you can use that value in functions to extract info about this specific serial device, namely dc_serial_device_get_name(3). iconic. π«Ά
When you're done, the serial device needs to be freed with dc_serial_device_free(3). don't ghost it, free it. π
And after iterating, the iterator itself needs to be freed using dc_iterator_free(3). both of them. cleanup era. π§
π reminder: there are two things to free here β thedc_serial_device_tvalues you get out (each one, withdc_serial_device_free(3)) and the iterator at the end (dc_iterator_free(3)). no leaving them lying around.
π₯ RETURN VALUES π₯
Returns DC_STATUS_SUCCESS on success, or another dc_status_t code on failure. that's it, that's the tea. β
On DC_STATUS_SUCCESS the returned iterator needs to be freed when done using dc_iterator_free(3). we said it in DESCRIPTION and we're saying it again because it matters, bestie. π
π SEE ALSO π
dc_context_new(3)dc_usbhid_iterator_new(3)dc_irda_iterator_new(3)dc_bluetooth_iterator_new(3)dc_serial_device_get_name(3)dc_serial_device_free(3)
(the whole iterator friend group π go read them, iykyk)
π AUTHORS π
The library βlibdivecomputerβ library was written by Jef Driesen, jef@libdivecomputer.org. legend behaviour honestly. π«‘
This manpage is written by Vincent Hagen, vinnie@script4web.nl. also iconic. π
and that's the page!! π this version came from Debian, dated June 5, 2020, and it's DC_SERIAL_ITERATOR_NEW(3) β go forth and enumerate your serial devices, bestie, you're gonna ate π
β¨
π¦ where this page comes from
- nixos 26.05: libdivecomputer 0.9.0
- nixpkgs unstable: libdivecomputer 0.9.0
- Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms