SerialPort: Port the stream routines to the new interface.

[GB.NET]
* BUG: SerialPort: Port the stream routines to the new interface. They just read and write directly now.
This commit is contained in:
gambas 2017-10-15 23:18:04 +02:00
parent 57bf22b786
commit afd759b6b3
2 changed files with 17 additions and 8 deletions

View file

@ -59,8 +59,6 @@ GB_STREAM_DESC SerialStream =
seek: CSerialPort_stream_seek,
tell: CSerialPort_stream_tell,
flush: CSerialPort_stream_flush,
eof: CSerialPort_stream_eof,
lof: CSerialPort_stream_lof,
handle: CSerialPort_stream_handle
};
@ -232,7 +230,7 @@ int CSerialPort_stream_close(GB_STREAM *stream)
return 0;
}
int CSerialPort_stream_lof(GB_STREAM *stream, int64_t *len)
/*int CSerialPort_stream_lof(GB_STREAM *stream, int64_t *len)
{
void *_object = stream->tag;
int bytes;
@ -255,9 +253,15 @@ int CSerialPort_stream_eof(GB_STREAM *stream)
if (ioctl(THIS->port,FIONREAD,&bytes)) return -1;
if (!bytes) return -1;
return 0;
}
}*/
int CSerialPort_stream_read(GB_STREAM *stream, char *buffer, int len)
{
void *_object = stream->tag;
return read(THIS->port, (void*)buffer, len);
}
/*int CSerialPort_stream_read(GB_STREAM *stream, char *buffer, int len)
{
void *_object = stream->tag;
int npos = -1;
@ -284,9 +288,16 @@ int CSerialPort_stream_read(GB_STREAM *stream, char *buffer, int len)
return -1;
return 0;
}
}*/
int CSerialPort_stream_write(GB_STREAM *stream, char *buffer, int len)
{
void *_object = stream->tag;
return write(THIS->port, (void*)buffer, len);
}
/*int CSerialPort_stream_write(GB_STREAM *stream, char *buffer, int len)
{
void *_object = stream->tag;
int npos = -1;
@ -306,7 +317,7 @@ int CSerialPort_stream_write(GB_STREAM *stream, char *buffer, int len)
return -1;
return 0;
}
}*/
static bool check_open(CSERIALPORT *_object)
{

View file

@ -72,8 +72,6 @@ typedef
int CSerialPort_stream_read(GB_STREAM *stream, char *buffer, int len);
int CSerialPort_stream_write(GB_STREAM *stream, char *buffer, int len);
int CSerialPort_stream_eof(GB_STREAM *stream);
int CSerialPort_stream_lof(GB_STREAM *stream, int64_t *len);
int CSerialPort_stream_open(GB_STREAM *stream, const char *path, int mode, void *data);
int CSerialPort_stream_seek(GB_STREAM *stream, int64_t pos, int whence);
int CSerialPort_stream_tell(GB_STREAM *stream, int64_t *pos);