Wszystkie wpisy, których autorem jest Mieszko

Dostęp do portu RS232 z poziomu OpenOffice

Serial Port Access

9 posts • Page 1 of 1

Serial Port Access

Postby andybuonviri » Sun Dec 09, 2007 8:04 am

Anyone know if it’s possible to access a serial port from a macro within Calc? From Excel, I’ve used something like this:

Open „COM8:9600,N,8,1″ For Output As #1
Print #1, mytext
Close #1

I tried the same thing in a Basic macro in Calc but it didn’t work.

andybuonviri
 
Posts: 1
Joined: Sun Dec 09, 2007 7:59 am

Re: Serial Port Access

Postby ms777 » Sun Dec 23, 2007 2:09 pm

Hi,

it is possible, but much more complicated. You will have to implement the code from http://support.microsoft.com/kb/823179/en-us (example module1.vb) in OO, using OO’s declare syntax. If yoy want to go that way let me know, if you need assistance

Good luck,

ms777

ms777
 
Posts: 119
Joined: Mon Oct 08, 2007 1:33 am

Re: Serial Port Access

Postby TerryE » Sun Dec 23, 2007 3:27 pm

If you read this article, it basically discusses two approaches. The first uses the MSComm Control (MSCOMM32.OCX). Do a google on „mscomm32.ocx download” for more information and avaialbility. There is a potential issue over legality / licensing. The second approach is to use some .Net controls which should be accessible through the UNO bridge, and these will require you to download the relevant .Net framework. However both are complicated solutions.

However, since you can use COM controls through the UNO bridge, this got me thinking about simpler non-MS approaches and did a google on „com port vbscript” (since the programmatic approach is the same as writing a vbscript, but I’ll get far more hits on vbscript than OOo Basic!). One of the early hits washttp://www.activexperts.com/activcomport/ which seems to do what you want. No guarantees. You will need to try it out etc. Also read section 3 of the SDK which tells you how to call com components, but once you’ve done that using a COM component is really quite straight forward but unfortunately MS OS (e.g. WinXP et al) specific.

And an apology to ms777 for seeming to jump on his/her suggestion. The truth is that I’ve come back to this „No responses” Q a couple of times and couldn’t think of an easy solution. It was his pointing out the kB article which gave me the idea, so the honours really belong to ms777 :-)

Ubuntu 11.04-x64 + LibreOffice 3 and MS free except the boss’s Notebook which runs XP + OOo 3.3.
TerryE
 
Posts: 1390
Joined: Sat Oct 06, 2007 10:13 pm
Location: UK

Re: Serial Port Access

Postby ms777 » Sat Aug 30, 2008 3:02 pm

it may be possible to use the Scripting.FileSystemObject (http://msdn.microsoft.com/en-us/library/hww8txat(VS.85).aspx). As I have no device to test on my com port, this is untested, but runs without error message:

CODE: SELECT ALL   EXPAND VIEW
Sub Main
oFSO  = createUnoService("com.sun.star.bridge.OleObjectFactory").createInstance("Scripting.FileSystemObject")

f = oFSO.OpenTextFile("COM1:9600,N,8,1", 1) 'for Reading
'  f = oFSO.OpenTextFile("COM1:9600,N,8,1", 2) 'for Writing
'  f.write("abc")
f.close

End Sub

Good luck,

ms777

ms777
 
Posts: 119
Joined: Mon Oct 08, 2007 1:33 am

Re: Serial Port Access

Postby wienerschnitzel » Sat Jan 17, 2009 7:52 am

Hi,
This seems to work. It would be nice though if I could register an event if a character arrives on the port. Is there a way to achieve this?
OOo 3.0.X on Ms Windows XP + linux
wienerschnitzel
 
Posts: 25
Joined: Sat Jan 17, 2009 7:48 am

Re: Serial Port Access

Postby ms777 » Sat Jan 17, 2009 7:58 am

wienerschnitzel wrote:Hi,
This seems to work. It would be nice though if I could register an event if a character arrives on the port. Is there a way to achieve this?

I would be very surprised if this i possible …

ms777
 
Posts: 119
Joined: Mon Oct 08, 2007 1:33 am

Re: Serial Port Access

Postby wienerschnitzel » Sat Jan 17, 2009 8:14 am

Hi ms777,

What I meant to say is that your sample code using the scripting.FileSystemObject seems to work. I just tested it with a loopback cable.

However, I need to be able to react on characters coming in on the serial port. I don’t think polling would work in my case.

A couple of posts up, somebody mentioned an activex control, but that one doesn’t seem to support events either.

I’m going to start a new topic.

cheers

OOo 3.0.X on Ms Windows XP + linux
wienerschnitzel
 
Posts: 25
Joined: Sat Jan 17, 2009 7:48 am

Re: Serial Port Access

Postby crythias » Sat Dec 18, 2010 4:51 am

While I know this is a VERY old topic, it is one that came up on searches for serial port interfaces, and there isn’t a good answer. So, I thought I’d post one.
All this information is for Windows.

I’m going to provide links to cost-free software, but they aren’t GPL. Your use of the components is up to your tolerance level.

Note: I’m building my interface in OOO Base. The concepts should be comparable if you use it for spreadsheet, etc.

First: the testing environment. http://www.aggsoft.com/com-port-emulator.htm is a neat little program that sends data to a com port — so if you create a text file with data you expect to receive from your data collection device, you can set the params to make your interface think it’s talking to your data collection device, without having the expensive(?) device in your hands.

Next: http://com0com.sourceforge.net/ This creates loopback nullmodem so you can program against the data being sent from the first device. For instance, COM5<->COM6, where COM6 might be the port being sent to from the com port emulator, and COM5 would be the COM port you’re building the interface against (listening to).

Both of the above have much more features than this purpose, but if you’ve set these up, you now have an environment against which you can test your interface.

To the programming part:
Get Port.dll from http://www.b-kainka.de/download.htm and set it in Windows/System32 (?) I suppose you could use IO.dll from http://www.geekhideout.com/iodll.shtml but I didn’t try it.

CODE: SELECT ALL   EXPAND VIEW
Declare Sub OPENCOM Lib "Port.dll" (ByVal A$)
Declare Function OPENCOM Lib "Port.dll" (ByVal A$) As Integer
Declare Sub CLOSECOM Lib "Port.dll" ()
Declare Function READBYTE Lib "Port.dll" () As Integer
Rem Port.dll is obtained from http://www.b-kainka.de/elepcfaq.htm (Near the bottom, Port.zip)
Rem the reference file for programming is located here: http://www.b-kainka.de/referenz.txt

Sub Main
Dim strByte as string
Dim strE as string
Dim oForm As object

Call OPENCOM ("COM5:4800,N,8,1")
strByte = READBYTE()
Do While strByte = -1 'wait until valid data comes
strByte = READBYTE()
Loop
strByte=Chr$(strByte)
strE = READBYTE()
Do While strE <> 10 'get data until end of line. This is an ASCII code number (BYTE) so change for your own end of data line.
Rem It assumes that there will be no errors on READBYTE, so if you want to detect for (-1), you should do it here.
strByte = strByte & chr$(strE)
strE = READBYTE()
Loop
CALL CLOSECOM() 'MUST CLOSE when completed loop

To make it react to an event, you can

CODE: SELECT ALL   EXPAND VIEW
Select Case strByte
Case "OK"
'stuff to do if you see an OK string
REM Check if you're connected to the data
if isNull( ThisDatabaseDocument.CurrentController.ActiveConnection ) then
ThisDatabaseDocument.CurrentController.connect()
end if
oForm = ThisDatabaseDocument.FormDocuments.getByName("PrintMe") 'title of the Document of type Form in "Forms"
oForm.open() 'open form
oForm = oForm.Component.DrawPage.Forms.getByName("Form") 'title of the form (internally. Might be "MainForm". Check the Form Navigator.)
oForm.Filter = "PhoneNumber LIKE " + "'" + strByte + "'" ' example to set a filter on a form
oForm.ApplyFilter = True 'Apply the filter
oForm.Reload 'Reload the form to reflect the filter change
End Select

End Sub

So what about writing to the port?

CODE: SELECT ALL   EXPAND VIEW
Declare Sub OPENCOM Lib "Port.dll" (ByVal A$)
Declare Function OPENCOM Lib "Port.dll" (ByVal A$) As Integer
Declare Sub SENDBYTE Lib "Port" (ByVal B%)

Sub Main
Dim I
Dim strSendstring as string
Call OPENCOM ("COM5:4800,N,8,1")

strSendstring = "Hello, World!" ' I don't know if you'll need it, but you can add  + Chr(10) + Chr(13) to provide line feeds/carriage returns
For I = 1 to Len(strSendstring)
Call SENDBYTE(Asc(Mid(strSendstring, I, 1)))
Next I
CALL CLOSECOM() 'MUST MUST MUST close or next OPENCOM will crash your app!
End Sub

To keep listening or keep sending, you can wrap stuff in a bigger loop. You might want to test versus a button press or value change to be able to exit your loop without having to end-task on OOO.

Hope it helps. If you need more instruction, use Google Translate against the documentation if you can’t read German. I may not ever return to answer any questions about this, but maybe someone will be helped by this being in one place.

OpenOffice 3.2.1 on Windows Vista
crythias
 
Posts: 1
Joined: Sat Dec 18, 2010 3:34 am

Re: Serial Port Access

Postby michaelgmaloy » Thu May 05, 2011 7:23 pm

everything seems to work fine
OpenOffice 3.1 on Windows 7 ipad app development
michaelgmaloy
 
Posts: 1
Joined: Thu May 05, 2011 7:22 pm

Nokia – kody, skróty klawiaturowe

Źródło: http://symbianworld.org/1121-nokia-secret-codes-a-handy-guide/

*#06# displays the IMEI – the serial number – of your phone. On the box of your device there should be the same number on the little sticker on one side of the box.
*#0000# displays the firmware and its date. Additionally there is the type (e.g. RM-159) and the name of your phone. This menu also gives you, if you own a N96, 5800, N85 and some other devices, the chance to update your firmware over the air.
*#92702689# (*#war_anty) displays the “warranty-menu” of your phone. Actually, in S60 it shows the time you spent on calls already.
*#2820# (*#bta_#) displays the bluetooth-address of your device. Every device has another bluetooth-address (works just if it has Bluetooth!).
*#62209526# (*#mac_wlan#) displays the MAC-address of your phone (works just if it has Wireless Lan!).

By pressing 0 (zero) for three seconds on the home-screen you easily can open the web browser.
By pressing the Menu/Home key for three seconds you open the task manager, which shows all opened applications.
Holding # for three seconds on the home screen you change the active profile to silent or back.
In the File manager, Photos application or Gallery you can sent your files really easily by pressing the green-answer key. Once you done that a lists pops up and you can decide whether you want to sent the file via e-mail, Bluetooth, upload it to a service or sent it as a message .

NOTE: The following codes can RESET your phone to the factory settings, all data on it will be deleted!
*#7780# (*#rst_#) does a soft-reset to your phone.
*#7370# (*#res_#) does a hard-reset to your phone.

“Smart-Sizing” the TS Client

“Smart-Sizing” the TS Client

Since the Windows XP timeframe, the TS Client has had the ability to run in “smart-sized” mode (users of Remote Assistance will be familiar with this mode). Smart-sized mode means that the entire remote desktop is always visible in the client window, with no scrollbars being necessary. In effect, for the same size client window, smart-sizing shows you more graphic data, while a non-smart-sized client window has to use scrollbars and shows much less.

Smart-sized client view of a user’s desktop:

Non-smart-size client view (with scrollbars) of the same desktop:

You cannot enable smart-sizing through the TS Client UI, but you can switch it on using RDP file settings. Add the following line to Default.rdp (or any other custom RDP file that you use):

smart sizing:i:1

The next time you connect, your client view will be smart-sized.

OpenOffice Portable 2.4 PL

Polski OpenOffice 2.4 w wersji portable razem z polskim słownikiem. Plik to samorozpakujące archiwum zgodne z formatem paf (skompilowana wersja instalatora portableapps.com z włączoną polską lokalizacją).

Ta wersja to połączenie:

zgodnie z instrukcją na stronie PortableApps

Pobierz: OpenOffice Portable 2.4 PL (PAF)