Avatar of prem13
prem13
 asked on

Powerbuilder 11.5

Can anybody provide some sample code for communication with serial port in powerbuilder 11.5...  I have to open,  read and close a card reader slot in Maxline Microplate reader

Thanks in advance
Editors IDEsProgramming

Avatar of undefined
Last Comment
Dirk Haest

8/22/2022 - Mon
sandeep_patel

Prem,

Most of the card readers comes with their SDK and it should have OCX to communicate with Card Reader. If OCX is available from that card reader provider, you can look at the events and functions of that OCX for communication.

Otherwise you will have use either windows API or FileRead and FileWrite functions from powerbuilder to open, close and read serialport.

Refer to below link for more detail.

http://groups.google.com/group/sybase.public.powerbuilder.general/browse_thread/thread/f415f86060bfdd9e

http://www.topwizprogramming.com/freecode_ftpedit.html

Thanks,
Sandeep
prem13

ASKER
Sandeep

Thanks for the mail.  In this case I don't have OCX to communicate with the reader and more over I have to deal with more than 2 models.

I tried as explained in the links but didn't succeed.  

Do u have any code examples of using these?

Thanks
Prem
diasroshan

Hi,

I have answered a similar question before. Please check the below link,
https://www.experts-exchange.com/Programming/Editors_IDEs/PowerBuilder/Q_23448847.html

Cheers,
Rosh
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
prem13

ASKER
Rosh

Thanks for the link.. but I was confused on how to use it.. can u explain it?

Thanks
Prem
ASKER CERTIFIED SOLUTION
diasroshan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
prem13

ASKER
Rosh,

Thanks for the tips. It was helpful and appreciate it.
MSCOMM32.OCX is registred
The zip files are imported to my Library.
Before Reading or Writing to the serial port, I have to open/close the tray of the machine connected to the serial port.  For this the command need to pass to the serial port is CLS/OPN.  I tried with Hyper teminal and it is working fine.  But when this command is passed from powerbuilder as
ole_1.object.output=  "CLS" + char (26)  
nothing is happening

Can you put some thoughts on this.  

Thanks
Prem
diasroshan

Hi,

what tray are u refering to.
where did u get the syntax "CLS" + char (26)  

i could probably check the link and help convert the syntax.

Also, please change the zone of this question to PowerBuilder Programming Language

Cheers,
Rosh
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
diasroshan

Also, try one of the below combinations,

ole_1.object.output=  "CLS" + "~H11"+ "~H5A"  
or
ole_1.object.output=  "CLS" + "~H11"+ "Z"
prem13

ASKER
Hi Rosh,

I got those commands from the Micro Plate reader help desk.  I am connecting this device to the serial port.  The operational procedure is ...
The device is having a tray where your can place the plate reader.  
Once the tray is slid into the machine (using the close (CLS) command), the read (RED) commant will read the plate.

On giving the open (OPN) command the tray will come out and the plate can be removed.

This can be done manually, (tried the operation with hyperterminal, it worked fine) but what I am trying to acheive is to get this done from the PB application we are having.

I do have a window to accept the baud, parity etc and once the user selects these from the dropdown and click on a button 'Process', it will trigger a user event thru which I am trying to do this.  Already defined the OCX control and the following code is there.  
-----------------------------------------------------------------------------------------
ole_1.Object.CommPort  = 1
ole_1.Object.Settings        = "9600,N,8,1"
//open the port
ole_1.Object.InputLen       = 0
ole_1.Object.InputMode       = 0
If Not ole_1.object.portopen Then
           ole_1.object.portopen = TRUE
End if      

ole_1.object.RThreshold = 10
ole_1.object.output =  "baud=9600 parity=N data=8 stop=1"

ole_1.object.output=  "CLS" + char (26)
------------------------------------------------------
But it is not closing the tray which is the first step.

I tried the commands you asked me to try and was given an error - "Error C0065: Invalid ~ hex character sequence in string"

Hope you got the scenario.  Appreciate your effort and  the time you are taking to help me out.

Thanks
Prem
prem13

ASKER
Hi Rosh,

I tried the commands you asked me to try and was given an error - "Error C0065: Invalid ~ hex character sequence in string".  I was able to get the error corrected by  changing it to

ole_1.object.output=  "CLS" + "~h11"+ "~h5a"  
or
ole_1.object.output=  "CLS" + "~h11"+ "z"

so the compilation did went thru without errors.  But on run nothing came up (the tray remained open.

Thanks
Prem
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Dirk Haest

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.