changeset 206:6fe0b4719c4d

8130236: UART.write is non-blocking Summary: added tcdrain Reviewed-by: alkonsta
author snazarki
date Fri, 03 Jul 2015 19:54:13 +0300
parents 6bb6fcb424ce
children a6ebf331b2a7
files src/share/linux/native/com/oracle/dio/uart/serial.c
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/linux/native/com/oracle/dio/uart/serial.c	Fri Jul 03 14:18:52 2015 +0400
+++ b/src/share/linux/native/com/oracle/dio/uart/serial.c	Fri Jul 03 19:54:13 2015 +0300
@@ -384,15 +384,14 @@
         return JAVACALL_OK;
     }
 
-    p->out_buffer_size = (size - p->out_total_written) > p->buffer_max_size ? p->buffer_max_size : (size - p->out_total_written);
-
-    p->out_buffer = javacall_malloc(p->out_buffer_size);
+    p->out_buffer_size = size;
+    p->out_buffer = javacall_malloc(size);
     if (NULL == p->out_buffer) {
         JAVACALL_REPORT_ERROR(JC_DIO,
                 "[UART] malloc error while jc_serial_write_common");
         return JAVACALL_OUT_OF_MEMORY;
     }
-    memcpy(p->out_buffer, buffer, p->out_buffer_size);
+    memcpy(p->out_buffer, buffer, size);
 
     if(0 == p->write_thread){
         // initialize write mutex
@@ -640,6 +639,9 @@
                 }
            }
         }//while
+
+        tcdrain(p->fd);// wait until whole packet is transmitted
+
         p->out_total_written += current_buffer_offset;
         //send signal or event in DA
         p->write_complete_cb(p, current_buffer_offset, error==JAVACALL_TRUE?JAVACALL_FAIL:JAVACALL_OK);