2020. 2. 12. 04:40ㆍ카테고리 없음
Raw Message I'm trying to develop a software using PowerBuilder which will capture data from the serial port of a PC. Essentially, the aim is to capture output from a digital weighing machine which is transmitted through the serial port of a connected PC. Does Powerbuilder have any facilities(functions/APIs) that meet the above requirement, that is, read the input at the serial port? We are using PowerBuilder 4.0. However, if these facilities are available in higher version, please mention that,too.
Your help will be much appreciated. The contact e-mail IDs are.@indiatimes.com. Raw Message Hi Rana, You can use any Windows API from PowerBuilder. PB itself does not have a function to do what you want though! - I don't know for sure, but I think there will be a way of picking up data through a serial port using a Windows API. You can research this online at MSDN. PB books (available online from Sybase) explain how to use Windows APIs from Powerbuilder.
Another option is to write the functionality you need in C, then call the dll from PowerBuilder. Hope this helps! I'm trying to develop a software using PowerBuilder which will capture data from the serial port of a PC.
Essentially, the aim is to capture output from a digital weighing machine which is transmitted through the serial port of a connected PC. Does Powerbuilder have any facilities(functions/APIs) that meet the above requirement, that is, read the input at the serial port? We are using PowerBuilder 4.0. However, if these facilities are available in higher version, please mention that,too. Your help will be much appreciated.
Hi,guys I need to use matlab to read and write serial port for getting data from my MCU. But actually the code is not efficiently in that I have to add a line 'pause (1);' in the code to make the code run well. If I do not, the code cannot read data later.
Jack - Perhaps you can make use of the second return parameter from which returns the number of variables read: A,count,msg = fread(.) returns the number of values read to count, and a warning message to msg if the read operation was unsuccessful. Is it safe to assume that once the start variable is read successfully, then those that follow should be available too? If so, then you could try the following. Remove the pause(1) that you added, and replace start=fread(s,1,'uint16'); with% declare a 10 millisecond delay delaySec = 0.01;% read from the serial port start,varcount,msg = fread(s,1,'uint16');% keep reading until the start data is returned while varcount0% pause pause(delaySec);% try again start,varcount,msg = fread(s,1,'uint16'); end The above will continue to read from the serial port until some data is returned. A problem is getting stuck in the while loop if no data is ever going to be sent again. To get around this, you could put a cap on the number of iterations in the while loop.% declare a 10 millisecond delay delaySec = 0.01;% if more than 10 seconds have passed without data, then exit maxIters = 10/delaySec;% use to keep track at which iteration we are at atIter = 1;% read from the serial port start,varcount,msg = fread(s,1,'uint16');% keep reading until the start data is returned while varcount0 && atIter.
Parallel Interface
Hi, I have tried your method,but it seems it doesn't work.I replace start=fread(s,1,'uint16'); with start,varcount,msg=fread(s,1,'uint16'); while varcount0 pause(0.1); start,varcount,msg=fread(s,1,'uint16'); end but it cannot work. - - - - - - - - - - - - - - - the function fread, if there is no data, will finish until the Timeout(10s by default); In my former code, If I add 'pause(1);', the next 'start=frea(s,1,'uint16')' can receive data;but if I do not, the next 'start=fread(s,1,'uint16')' have to wait for data for about 10s.
This 10s here is longer than the 1s in 'pause(1);'. Theoretically,It will receive some data,but actually it receives nothing.
Powerbuilder Serial Port Programming
In your code, enven if I change pause(0.1) to pause(2),it doesn't receive anything. The line 'start,varcount,msg=fread(s,1,'uint16');' still have to wait for 10s if no data input. I don't know what's wrong with my matlab code, it is very weird. 1s here work,but 10s in another place does not work any more.