diff --git a/ReadMe.txt b/ReadMe.txt index e9a5d2f..e3944a1 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -32,10 +32,13 @@ NOTES everything that you store in port 2 is lost just because the file "rom.49g" is READONLY. Since version 2.0, it is now possible from the menu to manage the Flash ROM file (it will fully replaces the ROM). - To speed up printing, set the 'delay' to 0 in the calculator's print options. -- The serial ports, wire or infrared (infrared limited to 2400 baud) are now supported through the USB port in mode OTG. - It uses the library https://github.com/mik3y/usb-serial-for-android, which allows to plug most of the serial USB adapters (only tested with Prolific), +- The serial ports, wire or infrared (infrared limited to 2400 baud) can now be used through the USB port in mode OTG. + It uses the library https://github.com/mik3y/usb-serial-for-android, which allows to plug most of the serial USB adapters (only tested with Prolific and Ch34x), without the need to be root. If it is not automatic, please, activate the OTG mode in your Android device, and then, - you should be able to see it in the Emu48 settings. If the adapter is unplugged then plugged back in, you may need to set the option again. + you should be able to see it in the Emu48 settings. + It is still experimental and I see some issues when sending characters from the emulator to a real HP48 or HP49 with the kermit protocol. + For the moment, the communication has been artificially slowed down in this direction. + If the adapter is unplugged then plugged back in, you may need to call OPENIO/CLOSEIO. NOT WORKING YET @@ -57,22 +60,12 @@ CHANGES Version 2.3 (2021-09-xx) -- Add the serial port support (via USB OTG). - FIX: When stop the app, Serial exception seems to delay the save of the calc state!!!! - FIX: Inform if the connection is not possible. - FIX: No 'No driver' on real device - FIX: ID change -> replace id by vendor:device ids? - BUG: From Windows to Android with HP49G QINHENG CH340 -> all character at once bug - No issue with Prolific PL2303GT3 - Not reproducible! - BUG: When openIO on real device, 1st OPENIO failed, 2nd OPENIO succeeded - TEST: With real HP48SX - TODO: Check the self test about UART +- Add an experimental serial port support (via USB OTG). - Show KML log on request. - Allows pressing a calculator button with the right button of the mouse and prevents its release to allow the On+A+F key combination (with Android version >= 5.0). - Update the embedded help file "Emu48.html" to the latest version. - Open an external web browser when you click an external links in the Help. -- Add Real blue 50g faceplate based on Eric KML script. +- Add Real blue 50g faceplate based on my calculator and on the KML script from Eric Rechlin. Version 2.2 (2020-12-09) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index d13f580..94c7423 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -17,7 +17,7 @@ cmake_minimum_required(VERSION 3.4.1) #add_compile_options(-DDEBUG_ANDROID_PAINT) #add_compile_options(-DDEBUG_ANDROID_THREAD) #add_compile_options(-DDEBUG_ANDROID_FILE) -add_compile_options(-DDEBUG_ANDROID_SERIAL) +#add_compile_options(-DDEBUG_ANDROID_SERIAL) #add_compile_options(-DNEW_WIN32_SOUND_ENGINE) diff --git a/app/src/main/assets/ReadMe.txt b/app/src/main/assets/ReadMe.txt index 93f901e..03c9809 100644 --- a/app/src/main/assets/ReadMe.txt +++ b/app/src/main/assets/ReadMe.txt @@ -32,10 +32,13 @@ NOTES everything that you store in port 2 is lost just because the file "rom.49g" is READONLY. Since version 2.0, it is now possible from the menu to manage the Flash ROM file (it will fully replaces the ROM). - To speed up printing, set the 'delay' to 0 in the calculator's print options. -- The serial ports, wire or infrared (infrared limited to 2400 baud) are now supported through the USB port in mode OTG. - It uses the library https://github.com/mik3y/usb-serial-for-android, which allows to plug most of the serial USB adapters (only tested with Prolific), +- The serial ports, wire or infrared (infrared limited to 2400 baud) can now be used through the USB port in mode OTG. + It uses the library https://github.com/mik3y/usb-serial-for-android, which allows to plug most of the serial USB adapters (only tested with Prolific and Ch34x), without the need to be root. If it is not automatic, please, activate the OTG mode in your Android device, and then, - you should be able to see it in the Emu48 settings. If the adapter is unplugged then plugged back in, you may need to set the option again. + you should be able to see it in the Emu48 settings. + It is still experimental and I see some issues when sending characters from the emulator to a real HP48 or HP49 with the kermit protocol. + For the moment, the communication has been artificially slowed down in this direction. + If the adapter is unplugged then plugged back in, you may need to call OPENIO/CLOSEIO. NOT WORKING YET @@ -57,12 +60,12 @@ CHANGES Version 2.3 (2021-09-xx) -- Add the serial port support (via USB OTG). +- Add an experimental serial port support (via USB OTG). - Show KML log on request. - Allows pressing a calculator button with the right button of the mouse and prevents its release to allow the On+A+F key combination (with Android version >= 5.0). - Update the embedded help file "Emu48.html" to the latest version. - Open an external web browser when you click an external links in the Help. -- Add Real blue 50g faceplate based on Eric KML script. +- Add Real blue 50g faceplate based on my calculator and on the KML script from Eric Rechlin. Version 2.2 (2020-12-09) diff --git a/app/src/main/cpp/win32-layer.c b/app/src/main/cpp/win32-layer.c index f183a49..d034591 100644 --- a/app/src/main/cpp/win32-layer.c +++ b/app/src/main/cpp/win32-layer.c @@ -336,7 +336,7 @@ BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,LPDWO SERIAL_LOGD("WriteFile(hFile: %p, lpBuffer: 0x%08x, nNumberOfBytesToWrite: %d) -> %d bytes\n%s", hFile, lpBuffer, nNumberOfBytesToWrite, writenByteCount, hexAsciiDump); free(hexAsciiDump); #endif - //Sleep(4); // Seems to be needed else the kermit packet does not fully reach the genuine calculator. + Sleep(4); // Seems to be needed else the kermit packet does not fully reach the genuine calculator. if(lpNumberOfBytesWritten) *lpNumberOfBytesWritten = (DWORD) writenByteCount; return writenByteCount >= 0; diff --git a/app/src/main/java/org/emulator/calculator/Serial.java b/app/src/main/java/org/emulator/calculator/Serial.java index f18c8f9..f823e26 100644 --- a/app/src/main/java/org/emulator/calculator/Serial.java +++ b/app/src/main/java/org/emulator/calculator/Serial.java @@ -28,7 +28,7 @@ import java.util.regex.Pattern; public class Serial { private static final String TAG = "Serial"; - private final boolean debug = true; + private final boolean debug = false; private final Context context; private final int serialPortId; @@ -260,22 +260,11 @@ public class Serial { return result; } - long maxWritePeriod = 4; //ms - long lastTime = 0; public synchronized int write(byte[] data) { if(!connected) return 0; - long currentTime = SystemClock.elapsedRealtime(); - long writePeriod = currentTime - lastTime; - - if(debug) Log.d(TAG, "write(data: [" + data.length + "]: " + Utils.bytesToHex(data) + ") writePeriod: " + writePeriod + "ms"); - - if(lastTime > 0 && writePeriod < maxWritePeriod) { - // Wait 1ms - (currentTime - lastTime)ms - android.os.SystemClock.sleep(maxWritePeriod - writePeriod); - } - lastTime = SystemClock.elapsedRealtime(); + if(debug) Log.d(TAG, "write(data: [" + data.length + "]: " + Utils.bytesToHex(data) + ")"); try { usbSerialPort.write(data, WRITE_WAIT_MILLIS);