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

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

Receive strings live. from serial port to PC.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
OpenOffice 4.1 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31279
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: 11361
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: 2784
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
Post Reply