Home » Developer & Programmer » Forms » Reading From Weight Scale RS232 (Win7 32Bit Forms6i)
Reading From Weight Scale RS232 [message #673689] Mon, 03 December 2018 09:28 Go to next message
h.aly-it
Messages: 3
Registered: December 2018
Junior Member
Dear All

I read All the Prev Post and tryed everything but nothing work please any one help me because iam involved in new Project to Read data From weight scale and dont know from where to start

Thank you
Re: Reading From Weight Scale RS232 [message #673690 is a reply to message #673689] Mon, 03 December 2018 10:36 Go to previous messageGo to next message
BlackSwan
Messages: 26322
Registered: January 2009
Location: SoCal
Senior Member
h.aly-it wrote on Mon, 03 December 2018 07:28
Dear All

I read All the Prev Post and tryed everything but nothing work please any one help me because iam involved in new Project to Read data From weight scale and dont know from where to start

Thank you

As a starting point & ignoring Oracle & Forms during the development process,
post working code that shows the computer can obtain & display the correct weight from the scale.
Re: Reading From Weight Scale RS232 [message #673691 is a reply to message #673689] Mon, 03 December 2018 11:43 Go to previous messageGo to next message
John Watson
Messages: 7698
Registered: January 2010
Location: Global Village
Senior Member
Welcome to the forum. Please read the OraFAQ Forum Guide and How to use code tags and make your code easier to read

Which posts have you read, and what did you try?
Re: Reading From Weight Scale RS232 [message #673692 is a reply to message #673689] Mon, 03 December 2018 12:44 Go to previous messageGo to next message
joy_division
Messages: 4916
Registered: February 2005
Location: East Coast USA
Senior Member
h.aly-it wrote on Mon, 03 December 2018 10:28
... tryed everything but nothing work
Maybe something more descriptive will get you a useful answer, but that surely will not.
Re: Reading From Weight Scale RS232 [message #673694 is a reply to message #673692] Mon, 03 December 2018 23:19 Go to previous messageGo to next message
h.aly-it
Messages: 3
Registered: December 2018
Junior Member
Thank you All

I Tried with the Form wt.fmb and with the Program unit SCALEWEIGHT

--**********************************************************
--Purpose
--This piece of Code reads data from com port 1 and 
--put the data in the given field. This task is being
--accomplished by using Microsoft Activ-X Control  
--MSCOMM32.OCX as called as 'Communication Control'
--**********************************************************
FUNCTION ScaleWeight RETURN CHAR IS
	receive   OLEVAR;
	v_buffer varchar2(10240);
	x number;
	Attempts Number:= 0; --counts the number of attempts to read the data from port
	v_FirstPoint number;  --used for taking the index of first symbol of 'kg'
	v_SecondPoint number;	--used for taking the index of second symbol of 'kg'
	v_BufferLength number; --stores the data stream get from com port
	v_DataStream varchar2(32767); -- gets the data from com port and stores in v_BufferLength
	v_ScaleLoopCnt number:=0;
	v_Number varchar2(200);
BEGIN    
	
	If (MSCOMMLib_IMSComm.PortOpen(:ITEM('BLOCK3.MSCOMMCONTROL').INTERFACE) = -1) then --open
		null;
	Else
		MSCOMMLib_IMSComm.CommPort(:ITEM('BLOCK3.MSCOMMCONTROL').INTERFACE,3);
		MSCOMMLib_IMSComm.Settings(:ITEM('BLOCK3.MSCOMMCONTROL').INTERFACE,'9600,N,8,1');
			--MSCOMMLib_IMSComm.Settings(:ITEM('BLOCK3.MSCOMMCONTROL').INTERFACE,ConnStr);
		MSCOMMLib_IMSComm.PortOpen(:ITEM('BLOCK3.MSCOMMCONTROL').INTERFACE,3);	
	End if;	

  --MSCOMMLib_IMSComm.PortOpen( comm_hnd, 1 );  
           
	--assigning the comport to active x control
	--check to see whether it is already open or closed

	v_FirstPoint := 0;
	v_SecondPoint := 0;
	v_buffer :=' ';
	v_BufferLength := 0;
	Attempts :=0;	
	loop			
		exit when (v_BufferLength > 150) or (Attempts > 200);
		begin
				mydelay(200);
				receive := MSCOMMLib_IMSComm.input(:ITEM('BLOCK3.MSCOMMCONTROL').INTERFACE);
				v_DataStream:= var_to_char(receive);
				v_BufferLength := NVL(length(v_buffer||v_DataStream),0);
				v_buffer := v_buffer||v_DataStream;
				Attempts := Attempts +1;

			exception when others then
			  --  Message(SQlcode||sqlerrm);
			   -- Message(SQlcode||sqlerrm);	
			   null;			
		end;
end loop;
BREAK;
			  	message(v_DataStream);
					message(v_DataStream);
					
				v_FirstPoint := nvl(instr(v_buffer,'kg',1),0);
				v_SecondPoint := nvl(instr(v_buffer,'kg',v_FirstPoint+2),0);
				v_buffer := substr(v_buffer,v_SecondPoint - 7 ,6);
				if (instr(v_buffer,',',1) =0) then --no comma exists in the data
							v_SecondPoint :=0;
				end if;				
				--v_buffer     := substr(v_buffer,1,2)||substr(v_buffer,4,3);
				v_buffer     := substr(v_buffer,1,7);--||substr(v_buffer,4,3);
				v_number := to_number(v_buffer);
  RETURN (v_number);  
END;

It Run Without any Errors but Nothing Return

Thank you


--moderator edit: [code] tags added, please do this yourself in future

[Updated on: Tue, 04 December 2018 01:04] by Moderator

Report message to a moderator

Re: Reading From Weight Scale RS232 [message #673696 is a reply to message #673694] Tue, 04 December 2018 00:38 Go to previous messageGo to next message
Michel Cadot
Messages: 66048
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

John Watson wrote on Mon, 03 December 2018 18:43
Welcome to the forum. Please read the OraFAQ Forum Guide and How to use code tags and make your code easier to read
...
Re: Reading From Weight Scale RS232 [message #673697 is a reply to message #673694] Tue, 04 December 2018 01:06 Go to previous messageGo to next message
John Watson
Messages: 7698
Registered: January 2010
Location: Global Village
Senior Member
Are you sure that it ran successfully? THere is a WHEN OTHERS clause that I think will suppress any error messages. Better remove it, and try again.
Re: Reading From Weight Scale RS232 [message #673698 is a reply to message #673697] Tue, 04 December 2018 01:25 Go to previous message
h.aly-it
Messages: 3
Registered: December 2018
Junior Member
i Remove it and it gives 100504 non oracle exception ..
I try to make sample program for testing the control in vb6 and it gives runtime error .. error reading from device
i replace in vb6 the Comm32 ocx with SCom32 i download it as a trail version from the the the form runs OK and i Receive the data
Previous Topic: access denied (java.lang.RuntimePermission loadLibrary.jacob) WEBUTIL
Next Topic: How to add picture on pdf page from oracle form 11g?
Goto Forum:
  


Current Time: Tue Dec 11 19:00:55 CST 2018