Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

SRP_COM

Hi,


I want to send a string from Oinsight to EDC machine.
The EDC connected to the computer using serial cable. Previously I execute a bat file to send data to the EDC :

PowerShell
PS C:\Users\Albert\Desktop> $port= new-Object System.IO.Ports.SerialPort COM5,9600,None,8,one
PS C:\Users\Albert\Desktop> $port.open()
PS C:\Users\Albert\Desktop> $port.writeline("Hello World")
PS C:\Users\Albert\Desktop> $message=$port.ReadLine()
PS C:\Users\Albert\Desktop> Write-Output $message


I have tried using SRP_COM, but it's not working :

If SRP_Com(COM5, "CREATE", "COM5") then
Temp = "Connected"
debug
end else
Error = SRP_Com("", "ERROR")
debug
end


What tool can I use to send a string directly from Oinsight ?


Regards and Thank you


Albert K

Comments

  • The "COM" in SRP_COM does not stand for "Communication Port" but rather "Common Object Model". Thus, this function is not suitable to your task in the way you are assuming.

    You need to use a utility that is programmed to talk to serial ports. We've used this one and it works pretty well. Because this is an OLE control, you will use SRP_COM to interact with its properties and methods.
  • >>Because this is an OLE control, you will use SRP_COM to interact with its properties and methods.

    Why would you not use the OI ole commands.
    How do you know that the OI ole would not work and you need to use srp_com.
  • How do you know that the OI ole would not work and you need to use srp_com.

    I'll answer your second question first. I didn't say that "OI ole would not work". I think you misread me or inferred my intent incorrectly. Yes, you can use either the OLE control in the Form Designer or the native COM commands in BASIC+. If, however, Albert needs to run this from a headless process (like a web service), then he must use the native COM commands in BASIC+ (or SRP_COM which is an alternative to the native COM commands).

    Why would you not use the OI ole commands.

    If by "OI ole commands" you mean the Form Designer OLE control and Set/Get_Property and Send_Message to interact with the control, then the only reason you would not is if you needed a headless solution (which I addressed above). If by "OI ole commands" you mean the native COM commands (like OLECreateInstance, OLEPutProperty, and OLECallMethod) then you might want to use SRP_COM for convenience (assuming you like the SRP_COM syntax better) or perhaps SRP_COM works better (one of the reasons SRP_COM exists is to address some edge cases where native COM commands weren't working).
  • edited June 2019
    Thank you, I will compare the two.
Sign In or Register to comment.