-/**
- * Create a backup of the current parameters of the specified serial port.
- *
- * @param fd File descriptor of the serial port.
- *
- * @return Pointer to a struct termios upon success, NULL upon errors.
- * It is the caller's responsibility to g_free() the pointer if no
- * longer needed.
- */
-SR_PRIV void *serial_backup_params(int fd)
-{
- sr_dbg("FD %d: Creating serial parameters backup.", fd);
-
-#ifdef _WIN32
- /* TODO */
-#else
- struct termios *term;
-
- if (!(term = g_try_malloc(sizeof(struct termios)))) {
- sr_err("termios struct malloc failed.");
- return NULL;
- }
-
- /* Returns 0 upon success, -1 upon failure. */
- if (tcgetattr(fd, term) < 0) {
- sr_err("FD %d: Error getting serial parameters: %s.",
- fd, strerror(errno));
- g_free(term);
- return NULL;
- }
-
- return term;
-#endif
-}
-
-/**
- * Restore serial port settings from a previously created backup.
- *
- * @param fd File descriptor of the serial port.
- * @param backup Pointer to a struct termios which contains the settings
- * to restore.
- *
- * @return 0 upon success, -1 upon failure.
- */
-SR_PRIV int serial_restore_params(int fd, void *backup)
-{
- sr_dbg("FD %d: Restoring serial parameters from backup.", fd);
-
- if (!backup) {
- sr_err("FD %d: Cannot restore serial params (NULL).", fd);
- return -1;
- }
-
-#ifdef _WIN32
- /* TODO */
-#else
- int ret;
-
- /* Returns 0 upon success, -1 upon failure. */
- if ((ret = tcsetattr(fd, TCSADRAIN, (struct termios *)backup)) < 0) {
- sr_err("FD %d: Error restoring serial parameters: %s.",
- fd, strerror(errno));
- }
-
- return ret;
-#endif
-}
-