1. Tracy Lamb
  2. PowerBuilder
  3. Tuesday, 30 August 2022 15:32 PM UTC

Hi all,

I'm just reviewing some very old code that used Serial Ports to communicate with instruments.  To open a port, I executed:

ii_ComID = OpenComm(as_com_port,ai_InBuffer_Size,ai_OutBuffer_Size)

OpenComm() doesn't appear to be supported anymore... at least I couldn't find it in the documentation.  I'm sure things have evolved since then, so I'm wondering how do I open and read and respond to an instrument on a serial port?

~~~Tracy

Accepted Answer
mike S Accepted Answer Pending Moderation
  1. Tuesday, 30 August 2022 15:51 PM UTC
  2. PowerBuilder
  3. # Permalink

OpenComm was never PB.  it looks like you probably were calling a dll

Comment
  1. Tracy Lamb
  2. Tuesday, 30 August 2022 16:03 PM UTC
You're right, I didn't check that first. I had created a user object uob_comport and declared a handful of Local External functions, all derived from user.exe:

FUNCTION int OpenComm(string IpcomName,int wInQue, int wOutQue) LIBRARY "user.exe" alias for "OpenComm;Ansi" .

Thank you, Mike!

  1. Helpful 1
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 30 August 2022 16:25 PM UTC
  2. PowerBuilder
  3. # 1

Hi Tracy;

   You can do this directly from PB as follows:

READ

integer li_FileNum
li_FileNum = FileOpen ( "COM1:", LineMode!, Write!, LockWrite!, Replace!)
FileRead / FileWrite ...

WRITE

ll_Job = fileopen ("COM1:", StreamMode!, Write!, Shared!)
filewrite (ll_Job, char(27) + char(112) + char(80) + char(25) + char(250))
fileClose(ll_Job)

Note: Just replace COM1: with the device name / port that you need to access

HTH

Regards ... Chris

Comment
  1. Chris Pollach @Appeon
  2. Tuesday, 30 August 2022 17:20 PM UTC
Kool! :-)
  1. Helpful
  1. Olan Knight
  2. Tuesday, 30 August 2022 18:22 PM UTC
Chris -

What's going on here? >>> filewrite (ll_Job, char(27) + char(112) + char(80) + char(25) + char(250))



Specifically this part: char(27) + char(112) + char(80) + char(25) + char(250)
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 30 August 2022 18:41 PM UTC
Hi Olan ... Just an example of sending "low level" machine codes to the serial device. Of course, you would need the manual for the device to know what "hex" codes to transmit in order for the device to respond to your App's requests. HTH Chris
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.