Script to write on COM port during MaximDL autosave session

Discussion in 'Scripting and Programming' started by Mallart, Aug 18, 2015.

  1. Mallart

    Mallart Cyanogen Customer

    Joined:
    Aug 18, 2015
    Messages:
    6
    Hello,

    I'm using MaximDL version 5 on a windows 7 labtop, and would like to write /get a VBScript allowing to send a simple string (like ":FT#") on a virtual COM port during autosave sessions (which can call automatically VBScripts). This is to alert an external focusing device when end of single exposures have been reached. This information will be used to allow refocusing between exposures (temperature compensation).

    I found difficulties to find such script on the web, can anybody help me ?

    Note : I would like to be able modifying the script using the notepad as a simple text file (with.vbs extension), and it should ne executable by "Microsoft ® Windows Based Script Host"

    Best regards,
    Emmanuel
     
  2. Adam Robichaud

    Adam Robichaud Staff Member

    Joined:
    Sep 29, 2014
    Messages:
    776
    Location:
    Ottawa
    I presume you're talking about serial port communication? A quick Google search turned up a few guides...

    http://www.activexperts.com/serial-port-component/howto/vbscript/

    I know it's been done before, because I've written some VB code that interfaces with a serial device. It just takes a little elbow grease. Good luck!
     
  3. Mallart

    Mallart Cyanogen Customer

    Joined:
    Aug 18, 2015
    Messages:
    6
    Thanks for this link, I already found it, but the example shown is much more than what I need, and therefore a little bit too complicated for my very low experience in VB Scripting.
    What I just need is to send specific characters to a predefined COM port, which is a virtual (through a FTDI USB to serial cable). I don't need anything more complicated.

    I would appreciate if you could help me writing a such simple script.

    Emmanuel
     
  4. Adam Robichaud

    Adam Robichaud Staff Member

    Joined:
    Sep 29, 2014
    Messages:
    776
    Location:
    Ottawa
    Unfortunately we don't provide support in writing scripts (unless, of course, our scripting interface is broken in some way — then, obviously, we'll jump in). That said: I would advise you do some research on MSCOMMLib, and try to get the following code to run.


    Sub DoComIO()
    Set com1 = CreateObject("MSCOMMLib.MSComm")

    com1.Settings = "9600,n,8,1"
    com1.CommPort = 1
    com1.InBufferCount = 0
    com1.PortOpen = True

    If Err then
    MsgBox "COM" & com1.CommPort & ": not opened."
    Exit Sub
    End If

    com1.Output = "a"

    Set com1 = Nothing
    End Sub

    DoComIO
     

Share This Page