[Solved] Receive strings from serial port to spreadsheet via Basic

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Locked
martg
Posts: 4
Joined: Fri Feb 28, 2020 1:24 pm

[Solved] Receive strings from serial port to spreadsheet via Basic

Post by martg »

Does Basic in Openoffice spreadsheet include commands to run something similar to the following test sw. eg. Below.
Specifically is "com1 " supported or is there an equivalent in Openoffice Basic?
as in. "Dim Incoming As String = com1.ReadLine()" eg.Below
( the aim is to import real time data from a usb. port to spreadsheet on PC. )


eg.
Function ReceiveSerialData() As String
' Receive strings from a serial port.
Dim returnStr As String = ""

Dim com1 As IO.Ports.SerialPort = Nothing
Try
com1 = My.Computer.Ports.OpenSerialPort("COM1")
com1.ReadTimeout = 10000
Do
Dim Incoming As String = com1.ReadLine()
If Incoming Is Nothing Then
Exit Do
Else
returnStr &= Incoming & vbCrLf
End If
Loop
Catch ex As TimeoutException
returnStr = "Error: Serial Port read timed out."
Finally
If com1 IsNot Nothing Then com1.Close()
End Try
Last edited by MrProgrammer on Sat Mar 15, 2025 3:37 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved]; Lock two-year-old topic
OpenOffice 4.1 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31344
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Receive strings live. from serial port to PC.spreadsheet via Basic

Post by Villeroy »

C++, Java, Python, or anything Microsoft has to offer, but not the supplementary StarBasic lingo.
Simply write the data into a text file and handle that with any software able to load text.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Zizi64
Volunteer
Posts: 11477
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Receive strings live. from serial port to PC.spreadsheet via Basic

Post by Zizi64 »

It worked with the ancient old versions of the OpenOffice.org, but not work with the newer version of the Apache OpenOffice nor LibreOffice:

https://forum.openoffice.org/en/forum/v ... .php?t=682
https://forum.openoffice.org/en/forum/v ... 20&t=31686
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
JeJe
Volunteer
Posts: 3064
Joined: Wed Mar 09, 2016 2:40 pm

Re: Receive strings live. from serial port to PC.spreadsheet via Basic

Post by JeJe »

You can declare Windows API functions in OOBasic. If you search for VB6 results for what you want - sometimes little translation is needed - so long as a few things like memory pointers aren't used it should run in OO.

I quickly found this,

http://www.thescarms.com/vbasic/CommIO.aspx

Edit: if you can't get something to work from within OO automation is another option.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
martg
Posts: 4
Joined: Fri Feb 28, 2020 1:24 pm

Re: Receive strings live. from serial port to PC.spreadsheet via Basic

Post by martg »

Thanks folks,
That last link looks promising.JeJe.
Any further suggestions most welcome.
OpenOffice 4.1 on Windows 7
User avatar
Jurassic Pork
Posts: 28
Joined: Wed Oct 25, 2017 7:55 am
Location: France

Re: Receive strings live. from serial port to PC.spreadsheet via Basic

Post by Jurassic Pork »

Hello,
with python macros , in Openoffice and LibreOffice calc it is possible to acquire data from serial port in real time. Require pyserial package (installed with pip manager of Apso).
it works under Windows and Linux.
Capture shows a calc workbook obtaining RMC dataframes for a serial port GPS every 2 seconds. Python is multi-thread, so you can work in the worksheet while the data are displayed.
OOSerialPortPython.gif
OOSerialPortPython.gif (118.3 KiB) Viewed 6252 times
Friendly, J.P
OpenOffice 4.1.14 , LibreOffice 7.6.2.1 on Windows 11/ LibreOffice 7.3.7 on Lubuntu 22.04
marcofelixiano
Posts: 1
Joined: Fri Mar 07, 2025 4:45 pm

Re: Receive strings live. from serial port to PC.spreadsheet via Basic

Post by marcofelixiano »

Jurassic Pork wrote: Wed Jul 31, 2024 7:33 am Hello,
with python macros , in Openoffice and LibreOffice calc it is possible to acquire data from serial port in real time. Require pyserial package (installed with pip manager of Apso).
it works under Windows and Linux.
Capture shows a calc workbook obtaining RMC dataframes for a serial port GPS every 2 seconds. Python is multi-thread, so you can work in the worksheet while the data are displayed.
OOSerialPortPython.gif
Friendly, J.P
Hi, Please can you share the file ?

Thankyou
OpenOffice 4.2.15 on Windows 10
User avatar
Jurassic Pork
Posts: 28
Joined: Wed Oct 25, 2017 7:55 am
Location: France

Re: Receive strings live. from serial port to PC.spreadsheet via Basic

Post by Jurassic Pork »

Hello,
marcofelixiano wrote: Fri Mar 07, 2025 4:51 pm Hi, Please can you share the file ?
File in attachment
Only works with LibreOffice >= 7.1 ( last APSO version requirement).
Don't forget to install the last version of APSO (the version with pip manager (ex v1.4.4) ) and install pySerial with the pip manager.
Friendly, J.P
Attachments
SerialPortTest.ods
(21.06 KiB) Downloaded 35 times
OpenOffice 4.1.14 , LibreOffice 7.6.2.1 on Windows 11/ LibreOffice 7.3.7 on Lubuntu 22.04
Locked