Powerbuilder 11.5

prem13
prem13 used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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

Author

Commented:
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
Hi,

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

Cheers,
Rosh
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Rosh

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

Thanks
Prem
Hi,

Extract the attached zip.

Rename the file extensions as below,
n_cst_serialcom.sru
st_commtimeouts.srs
st_dcb.srs
st_overlapped.srs

Import the above userobject and 3 structures to your library.

The above objects will help you communicate with serial port.

You will need the following OCX -->MSCOMM32.OCX
if its not present u need to copy it onto ur PC....

next u need to register it there....

u can do the registering as follows....

Go to Start---> Run

in Run , browse and go to location of REGSVR32.EXE

then add a space and give the location of ur MSCOMM32.OCX file

it might look as follows...
C:\WINNT\system32\REGSVR32.EXE  C:\MSCOMM32.OCX

press OK and message of success will appear...

Now, from your PB object u can refer the above userobject and call its function like 'Read' and 'Write'
Eg.

n_cst_serialcom ln_cst_serialcom

ln_cst_serialcom.Open(1)
ln_cst_serialcom.Read(100)


Hope this helps,

Cheers,
Rosh
commport.zip

Author

Commented:
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
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
Also, try one of the below combinations,

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

Author

Commented:
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

Author

Commented:
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
Dirk HaestProject manager

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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial