|
Post by ardentcrest on Feb 11, 2021 17:35:22 GMT -5
To start off Im a 50+ novice whose programming skills never passed programming on the ZX Spectrum back in the 80's/90's I have been given a weather station whose software has not been updated in over 9 years. So looking for a way to read the data coming from the station I search and found, 1 ) libusb licensed under the GNU Lesser General Public License. and 2 ) fowsr (Fine Offset Wireless Weather Station Reader) ..... GNU General Public License as published by the Free Software Foundation ..... I am looking for help/pointers on how to convert github.com/ajauberg/fowsr/blob/master/fowsr.src/fowsr.c in to LB any help would be appreciated. If anything the libusb could be very useful to the LB community.
|
|
|
Post by zxrportugal on Feb 11, 2021 17:49:09 GMT -5
hi i´m a novice , this a example program that i used to receive data from my siemens s200 plc by usb (using a chinese ppi to usb converter ). if no connection to the right port a error ocours (no error handling for that made....this is an example)
'SETUP THE GRAPHICAL USER INTERFACE BackgroundColor$ = "blue" ForegroundColor$ = "red"
WindowWidth = DisplayWidth WindowHeight = DisplayHeight - 5 UpperLeftX = 0 UpperLeftY = 0 STATICTEXT #main.Label1, "Dados Recebidos", 4, 200, 100, 20
TEXTBOX #main.DataReceived, 4, 240, 150, 20 STATICTEXT #main.Label1, "Mensagem a enviar" , 4, 80, 100, 20 TEXTBOX #main.DataToSend, 4,100, 150, 20
BUTTON #main.send, "Enviar >>", [SendData],ul, 170, 100 ,200, 25 button #main.botao1, "botao1", [Botao1] ,ul, 400, 250 ,100, 75 BUTTON #main.botao2, "botao2", [Botao2] ,ul, 650, 250 ,100, 75 BUTTON #main.botao3, "botao3", [Botao3] ,ul, 900, 250 ,100, 75 BUTTON #main.botao4, "botao4", [Botao4] ,ul, 1150, 250 ,100, 75 BUTTON #main.botao5, "sequenciador 123", [Botao5] ,ul, 400, 550 ,100, 75 BUTTON #main.botao4, "reset sequenciador", [Botao6] ,ul, 525, 550 ,100, 75
STATICTEXT #main.credit, "By SPD ", 4, 160*2+30, 200, 30 graphicbox #main.0, 400, 50, 100, 100 graphicbox #main.1, 650, 50, 100, 100 graphicbox #main.2, 900, 50, 100, 100 graphicbox #main.3, 1150, 50, 100, 100 open "comunicação porta Serie" for window as #main
print #main, "trapclose [close]" print #main.DataReceived, "Dados a receber aparecem aqui..." print #main.DataToSend, "escreva a mensagem a enviar..." print #main.0, "home" 'center the pen print #main.0, "down" 'ready to draw print #main.0, "fill black" 'fill the graphics area black print #main.1, "home" 'center the pen print #main.1, "down" 'ready to draw print #main.1, "fill black" 'fill the graphics area black print #main.2, "home" 'center the pen print #main.2, "down" 'ready to draw print #main.2, "fill black" 'fill the graphics area black print #main.3, "home" 'center the pen print #main.3, "down" 'ready to draw print #main.3, "fill black" 'fill the graphics area black
PROMPT "Escreva o numero da porta serie"; portnumber$ 'ask the user to enter the number of the com port they want to use
if portnumber$="" then portnumber$="1" 'invalid numbers will result in an error
'OPEN THE SERIAL PORT oncomerror [myComErrorHandler]
open "COM";portnumber$;":9600,N,8,1,ds0,cs0" for random as #commsport x=0 z=0
'MAIN PROGRAM LOOP [start] scan
calldll #kernel32,"Sleep",50 as ulong,r as void 'sleep for 2ms datalength=lof(#commsport) if datalength>0 then RXdata$ = (input$(#commsport, datalength)) 'read the contents of the receive buffer RXdata$ (3)=dados$ print #main.DataReceived, RXdata$ print RXdata$ : print time$()
z=z+1
'show the result on screen if x>0 then goto [Botao5] goto [start]
'GET DATA FROM THE TEXTBOX AND SEND IT OUT OF THE SERIAL PORT WHEN THE 'SEND' BUTTON IS PRESSED [SendData] print #main.DataToSend, "!contents? TXdata$" print #commsport, TXdata$ goto [start]
[Botao1] s$="s0@" print #commsport, s$ if s$= "s0@" then print #main.0, "fill red"
scan if s$<> "s0@" then print #main.0, "fill black" s$="0" scan if s$<> "s0@" then print #main.0, "fill black" goto [start]
[Botao2] s$="s1@" print #commsport, s$ if s$= "s1@" then print #main.1, "fill red" scan for t=1 to 200 next t if s$= "s1@" then print #main.1, "fill red" scan if s$<> "s1@" then print #main.1, "fill black"
s$="1" scan if s$<> "s1@" then print #main.1, "fill black" goto [start]
[Botao3] s$="s2@" print #commsport, s$ if s$= "s2@" then print #main.2, "fill red"
for t=1 to 200 next t
s$="2" if s$<> "s2@" then print #main.2, "fill black" goto [start]
[Botao4] s$="s3@" print #commsport, s$ if s$= "s3@" then print #main.3, "fill red"
for t=1 to 200 next t
s$="3" if s$<> "s3@" then print #main.3, "fill black" goto [start]
[Botao5] x=x+1
s$="s3@" print #commsport, s$ if s$= "s3@" then print #main.3, "fill red" for y=0 to 500
next y s$="3" gosub [estadosaídas] s$="s0@" print #commsport, s$ if s$= "s0@" then print #main.0, "fill red" for y=0 to 500
next y s$="0" gosub [estadosaídas] s$="s1@" print #commsport, s$ if s$= "s1@" then print #main.1, "fill red" for y=0 to 500
next y s$="1" gosub [estadosaídas] s$="s2@" print #commsport, s$ if s$= "s2@" then print #main.2, "fill red" for y=0 to 500
next y s$="2" gosub [estadosaídas] goto [start]
[Botao6] x=0 s$="reset sequenciador" gosub [estadosaídas] goto [start]
[estadosaídas] if s$= "s0@" then print #main.0, "fill red" if s$<> "s0@" then print #main.0, "fill black" if RXdata$= "s0r@" then print #main.0, "fill black" if RXdata$= "s0s@" then print #main.0, "fill red"
if s$= "s1@" then print #main.1, "fill red"
if s$<> "s1@" then print #main.1, "fill black" if RXdata$= "s1r@" then print #main.1, "fill black" if RXdata$= "s1rs@" then print #main.1, "fill red" if s$= "s2@" then print #main.2, "fill red" if s$<> "s2@" then print #main.2, "fill black" if RXdata$= "s2r@" then print #main.2, "fill black" if RXdata$= "s2s@" then print #main.2, "fill red" if s$= "s3@" then print #main.3, "fill red" if s$<> "s3@" then print #main.3, "fill black" if RXdata$= "s3r@" then print #main.3, "fill black" if RXdata$= "s3s@" then print #main.3, "fill red" return
'HANDLE THE COMMS ERROR AND GIVE DETAILS OF THE PROBLEM
[myComErrorHandler] oncomerror NOTICE "Error: "; ComError$; chr$(13) ;"Port number: "; ComPortNumber; chr$(13) ;"Error code: ";ComErrorNumbe
'TIDY UP AND END THE PROGRAM [close] close #commsport close #main
|
|
|
Post by Rod on Feb 12, 2021 3:21:55 GMT -5
Ok, we are missing a few steps here. First off is the assumption that rs232 serial is involved at all. The weather station is linked to the PC by a USB lead. That means it MIGHT use rs232. But it also might just use its own USB coms, we need that info.
So the very first step is to know the weather station make and model number and to find it’s online support pages. That may tell us how it communicates and may offer .dll support for communicating. It may also confirm that it is a proprietary usb based coms system.
We can’t just pick ANY usb .dll unless the weather station is know to communicate in a standard format. So have you chosen the dll you have because it is proven to work with the weather station?
So first questions
Make and model of the weather station?
Is there a documented coms standard you know it uses?
If you plug the weather station into a live PC does a new serial port appear under devices?
Edit, both those links look like very hard work. If we can get to a support page it might be a whole lot simpler than those pages suggest.
|
|
|
Post by tenochtitlanuk on Feb 12, 2021 4:38:19 GMT -5
|
|
|
Post by Rod on Feb 12, 2021 4:43:30 GMT -5
I see in a earlier post you sent the .dll that ships with the weather station. That might be useful. But to be useful we need to see the support documentation. It may still exist on line. I cant see any clues in the .dll about where it came from.
So we have the .dll driver but we don't know how it works. The really hard way to do this is to monitor the link and watch how it converses with the weather station. Then we might work out the data transmission protocol. Even if the transmission is rs232 it can still be a heck of a job working out what messages to send and how to interpret the response. Given we actually have a .dll I don't think the transmission will be rs232. But you can confirm that by looking to see if it establishes a com port when you plug it in.
Look at devices, serial ports before and after it is plugged in.
Documentation will be the key to opening this.
|
|
|
Post by ardentcrest on Feb 12, 2021 8:31:09 GMT -5
At work at the moment. tenochtitlanuk CumulusMX is good but it gives me some wrong info on its page. data transmission is usb to usb cable. the station is an Elecsa AstroTouch 6975,same one as tenochtitlanuk ,online support pages are gone. the Weather station memory map is at www.jim-easterbrook.me.uk/weather/mm/there is also some python code at github.com/jim-easterbrook/pywws which also get the data from the station (usb to usb)
|
|
|
Post by Rod on Feb 14, 2021 5:58:13 GMT -5
John is showing us that he can get access to the devices data history via an ASC based CSV file. Is that a solution for you? I assume John does some manual file exporting or reading.
|
|
|
Post by ardentcrest on Feb 14, 2021 7:23:42 GMT -5
I could but I would have to have the CumulusMX exe running in the background. Is there a way to start and stop an external exe from with in LB?
|
|
|
Post by Rod on Feb 14, 2021 8:55:41 GMT -5
I posted this a few weeks ago. Others posted alternative methods to close a .exe / file. So you would use run to start the weather program, but I don't know how you would automate the export of the data within the weather program.. Taskkill will close the program but it is quite a brutal way to end a program. A bit like Task Manager's kill program.
nomainwin run "notepad.exe" timer 5000,[done] wait [done] timer 0 run "taskkill /im notepad.exe" end
|
|