[PD] comport rxerrors on W10
Martin Peach
chakekatzil at gmail.com
Wed Dec 2 21:51:27 CET 2015
Here is a diff file against the current comport.c in svn which attempts to
fix the issue (also fixes a small bug and stops warnings about insecure
strcpy).
I tested it on Win7 but Win7 doesn't use that part of the code so I don't
know if it really works. Also my WIn10 machine seems to be dead now, so I
can;t test it there either :(.
Martin
On Wed, Dec 2, 2015 at 1:58 PM, <rolfm at dds.nl> wrote:
> is there's any progress on this subject?
>
> i hesitate to ask, because it's beyond my capabilities to make a
> constructive contribution in this.
>
> but i'm quite handicapped without comport in W10.
>
> luckily i still have a XP desktop as a backup.
>
>
>
> rolf
>
> _______________________________________________
> Pd-list at lists.iem.at mailing list
> UNSUBSCRIBE and account-management ->
> http://lists.puredata.info/listinfo/pd-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20151202/35739a31/attachment.html>
-------------- next part --------------
Index: comport.c
===================================================================
--- comport.c (revision 17597)
+++ comport.c (working copy)
@@ -419,7 +419,7 @@
if (fd == INVALID_HANDLE_VALUE) return -1;
status = EscapeCommFunction(fd, dwFunc);
- if (status != 0) return nr;
+ if (status != 0) return on;
return -1; /* didn't work, GetLastError tells why */
}
@@ -1083,6 +1083,7 @@
/*osReader.Pointer = 0; seems MinGW doesn't knoow about this one */
osReader.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if(ReadFile(x->comhandle, x->x_inbuf, x->x_inbuf_len, &dwRead, &osReader))
+ //if (ReadFile(x->comhandle, x->x_inbuf, NULL, &dwRead, &osReader))
{
if(dwRead > 0)
{
@@ -1095,8 +1096,27 @@
else
{
whicherr = GetLastError();
- if (whicherr != ERROR_IO_PENDING)
- err = -1;
+ if (whicherr == ERROR_IO_PENDING)
+ {
+ //post("iopending\n");
+ if (GetOverlappedResult(x->comhandle, &osReader, &dwRead, FALSE)) // don't wait
+ {
+ //post("dwRead %ld\n", dwRead);
+ if (dwRead > 0)
+ {
+ for (dwX = 0; dwX < dwRead;dwX++)
+ {
+ outlet_float(x->x_data_outlet, (t_float)x->x_inbuf[dwX]);
+ }
+ }
+ }
+ else
+ {
+ whicherr = GetLastError();
+ if (whicherr != ERROR_IO_PENDING) err = -1;
+ }
+ }
+ else err = -1;
}
CloseHandle(osReader.hEvent);
#else
@@ -1303,7 +1323,11 @@
/* Open the Comport for RD and WR and get a handle */
/* this line should use a real serial device */
- strncpy(test.serial_device_prefix, serial_device_prefix, strlen(serial_device_prefix)+1);
+#ifdef _MSC_VER
+ strncpy_s(test.serial_device_prefix, strlen(serial_device_prefix) + 1, serial_device_prefix, strlen(serial_device_prefix) + 1);
+#else
+ strncpy(test.serial_device_prefix, serial_device_prefix, strlen(serial_device_prefix) + 1);
+#endif
test.baud = fbaud;
test.data_bits = 8; /* default 8 data bits */
test.parity_bit = 0;/* default no parity bit */
@@ -1321,7 +1345,11 @@
x = (t_comport *)pd_new(comport_class);
x->comport = test.comport;/* com_num */
- strncpy(x->serial_device_prefix,serial_device_prefix,strlen(serial_device_prefix)+1);
+#ifdef _MSC_VER
+ strncpy_s(x->serial_device_prefix, strlen(serial_device_prefix) + 1, serial_device_prefix, strlen(serial_device_prefix) + 1);
+#else
+ strncpy(x->serial_device_prefix, serial_device_prefix, strlen(serial_device_prefix) + 1);
+#endif
x->serial_device = test.serial_device; /* we need this so 'help' doesn't crash */
x->baud = test.baud;
@@ -2013,7 +2041,7 @@
null_tv.tv_usec = 0;
#endif /* NOT _WIN32 */
verbose(-1, "comport - PD external for unix/windows\n"
- "LGPL 1998-2012, Winfried Ritsch and others (see LICENSE.txt)\n"
+ "LGPL 1998-2015, Winfried Ritsch and others (see LICENSE.txt)\n"
"Institute for Electronic Music - Graz");
}
More information about the Pd-list
mailing list