cake
/
libp7
Archived
1
0
Fork 1
This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
libp7/src/protocol/legacy/init.c.draft

48 lines
1.7 KiB
Plaintext

/* *****************************************************************************
* protocol/legacy/init.c -- initialize the legacy communication.
* Copyright (C) 2016-2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
*
* This file is part of libp7.
* libp7 is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version.
*
* libp7 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libp7; if not, see <http://www.gnu.org/licenses/>.
* ************************************************************************** */
#include <libp7/internals.h>
/* ************************************************************************** */
/* Initialization */
/* ************************************************************************** */
/**
* p7_legacy_start:
* Start the communication.
*
* @arg handle the handle.
* @return the error, if any.
*/
int p7_legacy_start(p7_handle_t *handle)
{
/* receive the attention request */
unsigned char byte;
p7_read(handle->stream, &byte, 1, 0);
if (byte != 0x15) return (p7_error_unknown);
/* send the device present */
byte = 0x13;
p7_write(handle->stream, &byte, 1);
/* receive first packet */
p7_legacy_recv(&packet);
}