QB64 Phoenix Edition
Lakeshore 218 Temperature Monitor - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://staging.qb64phoenix.com/forumdisplay.php?fid=10)
+---- Thread: Lakeshore 218 Temperature Monitor (/showthread.php?tid=892)

Pages: 1 2


RE: Lakeshore 218 Temperature Monitor - SpriggsySpriggs - 09-15-2022

By the way.... Since you have piqued my interest with this project idea, I've decided to take a gander at the MSDN for COM port communications. I'm working on a little something that you might end up being able to try in the next couple of days...

Code: (Select All)
Option Explicit
$NoPrefix
$Console:Only

Const GENERIC_READ = &H80000000
Const GENERIC_WRITE = &H40000000

Const OPEN_EXISTING = 3

Const CBR_110 = 110
Const CBR_300 = 300
Const CBR_600 = 600
Const CBR_1200 = 1200
Const CBR_2400 = 2400
Const CBR_4800 = 4800
Const CBR_9600 = 9600
Const CBR_14400 = 14400
Const CBR_19200 = 19200
Const CBR_38400 = 38400
Const CBR_57600 = 57600
Const CBR_115200 = 115200
Const CBR_128000 = 128000
Const CBR_256000 = 256000

Const EVENPARITY = 2
Const MARKPARITY = 3
Const NOPARITY = 0
Const ODDPARITY = 1
Const SPACEPARITY = 4

Const DTR_CONTROL_DISABLE = &H00
Const DTR_CONTROL_ENABLE = &H01
Const DTR_CONTROL_HANDSHAKE = &H02

Const RTS_CONTROL_DISABLE = &H00
Const RTS_CONTROL_ENABLE = &H01
Const RTS_CONTROL_HANDSHAKE = &H02
Const RTS_CONTROL_TOGGLE = &H03

Const ONESTOPBIT = 0
Const ONE5STOPBITS = 1
Const TWOSTOPBITS = 2

Type DCB
    As Unsigned Long DCBlength, BaudRate
    As Bit fBinary, fParity, fOutxCtsFlow, fOutxDsrFlow
    As _Bit * 2 fdtrControl
    As Bit fDsrSensitivity, fTXContinueOnXoff, fOutX, fInX, fErrorChar, fNull
    As _Bit * 2 fRtsControl
    As Bit fAbortOnError
    As _Bit * 17 fDummy2
    As Unsigned Integer wReserved, XonLim, XoffLim
    As Byte ByteSize, Parity, StopBits
    As Unsigned Byte XonChar, XoffChar, ErrorChar, EofChar, EvtChar
    As Unsigned Integer wReserved1
End Type

Declare CustomType Library
    Function CreateFile%& (ByVal lpFileName As Offset, Byval dwDesiredAccess As Unsigned Long, Byval dwShareMode As Unsigned Long, Byval lpSecurityAttributes As Offset, Byval dwCreationDisposition As Unsigned Long, Byval dwFlagsAndAttributes As Unsigned Long, Byval hTemplateFile As Offset)
    Function GetCommState& (ByVal hFile As Offset, Byval lpDCB As Offset)
    Function SetCommState& (ByVal hFile As Offset, Byval lpDCB As Offset)
End Declare

Dim As DCB dcb
Dim As Offset hCom
Dim As Long fSuccess
Dim As String pcCommPort: pcCommPort = "COM1" + Chr$(0)

hCom = CreateFile(Offset(pcCommPort), GENERIC_READ Or GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0)
If hCom = -1 Then End

fSuccess = GetCommState(hCom, Offset(dcb))
If fSuccess Then
    PrintCommState dcb

    dcb.BaudRate = CBR_9600
    dcb.ByteSize = 8
    dcb.Parity = NOPARITY
    dcb.StopBits = ONESTOPBIT

    fSuccess = SetCommState(hCom, Offset(dcb))
    If fSuccess Then
        fSuccess = GetCommState(hCom, Offset(dcb))
        If fSuccess Then
            PrintCommState dcb
            Print "Serial port "; pcCommPort; " successfully reconfigured"
        Else
            End
        End If
    Else
        End
    End If
Else
    End
End If

Sub PrintCommState (dcb As DCB)
    Print "BaudRate ="; dcb.BaudRate; ", ByteSize ="; dcb.ByteSize; ", Parity ="; dcb.Parity; ", StopBits ="; dcb.StopBits
End Sub


[Image: image.png]


RE: Lakeshore 218 Temperature Monitor - Pete - 09-15-2022

If you're working on a Linux S.O.L.
If you're working on a Linux S.O.L.
If you're working on a Linux
By the time this app is finished
If you're working on a Linux S.O.L.

Sorry, couldn't resist.

Oh well, you can't please everyone. But maybe Linux and Mac users have other options, including WINE.

@Spriggsy

Best of luck with this endeavor,and a question: Would this lead to to ability to make a phone app that would be able to dial out over a router / modem, instead of a phone jack? I used to have a routine that worked on a phone jack, but never one that would connect over a router / modem. My current phone is on a cable modem.

Pete


RE: Lakeshore 218 Temperature Monitor - SpriggsySpriggs - 09-15-2022

(09-15-2022, 07:40 PM)Pete Wrote: If you're working on a Linux S.O.L.
If you're working on a Linux S.O.L.
If you're working on a Linux
By the time this app is finished
If you're working on a Linux S.O.L.

I love that, @Pete . That's hilarious!

(09-15-2022, 07:40 PM)Pete Wrote: Best of luck with this endeavor,and a question: Would this lead to to ability to make a phone app that would be able to dial out over a router / modem, instead of a phone jack? I used to have a routine that worked on a phone jack, but never one that would connect over a router / modem. My current phone is on a cable modem.

I'm not sure about that. That sounds like VoIP.


RE: Lakeshore 218 Temperature Monitor - Pete - 09-15-2022

(09-15-2022, 07:43 PM)Spriggsy Wrote:
(09-15-2022, 07:40 PM)Pete Wrote: If you're working on a Linux S.O.L.
If you're working on a Linux S.O.L.
If you're working on a Linux
By the time this app is finished
If you're working on a Linux S.O.L.

I love that, @Pete . That's hilarious!

(09-15-2022, 07:40 PM)Pete Wrote: Best of luck with this endeavor,and a question: Would this lead to to ability to make a phone app that would be able to dial out over a router / modem, instead of a phone jack? I used to have a routine that worked on a phone jack, but never one that would connect over a router / modem. My current phone is on a cable modem.

I'm not sure about that. That sounds like VoIP.

@Spriggsy

And the jingle comes back to bite me! VoIP. Old school was to use either use Windows Phone Dialer or write your own. Both went out over an RS232 plug-in modem. Ah, the slow old days of dial up internet. Hey to get away from being serious for a moment, funny and true story. There was a company back then that time period that had a similar business service. They wanted to be known as Dial-U-Pass, but when they domained their company name, it of course came out as... www.dialupass.com. I don't know about you, but I have a hard enough time placing a number from the outside world, and no one gets good reception inside a tunnel, anyway.

I think on my old rip/xp, I had a phone jack in the back, and rigged up some program that would dial out over it, so basically a phone number stored in a program could be clicked and the phone would start dialing. That's basically what I'm looking for now, a way to get my computer to send the number to my cable phone, so I can dial out over that connection directly by "dialing" (clicking) the number from my computer. Since the cable modem has a phone jack, I think I'd have to have a way to go through my internet connection to the modem, or get some device attached to my laptop I can put a phone cord that goes to that modem, just the way my current phone connects to the back of that modem, now.

Pete


RE: Lakeshore 218 Temperature Monitor - SpriggsySpriggs - 09-15-2022

That sounds like something that while I might be able to fix up would be impossible for me to test because I don't have this sort of setup. I'd have to do a lot of research online to see if there is any code I can hack apart for you. We shall see!