Welcome! Log In Create A New Profile

Advanced

sWrite Implementation in Windev Mobile (WM)

Posted by Mitchell 
Mitchell
sWrite Implementation in Windev Mobile (WM)
February 14, 2009 02:26PM
how to implement sWrite ? the code below doesn't do anything on the com port.
=============
sOpen(4, 5000, 5000, 5000)

// Initializes the settings of the serial port
sParameter(...
4, ... // Port
9600, ... // Rate
0, ... // Parity: 0=None, 1=Even, 2=Odd
8, ... // Nb of data bits
1, ... // Nb of stop bits
// 0=1 stop bit, 1=1.5 stop bits, 2=2 stop bits
False, ... // DTR/DSR is ignored
False, ... // RTS/CTS is ignored
False) // XON/XOFF is ignored

Number is int

sMessage is string

sMessage = "TESTING PRINT ONLY DIRECT TO SERIAL PORT COM 4"
// Send a message to the COM4 output buffer
sWrite(4, sMessage)
// Wait for the end of the write operation
LOOP
IF sInExitQueue(4) = 0 THEN BREAK
END
Info("End of write operation")

sClose(4)

IF ErrorOccurred THEN
Error("Unable to initialize the port", ErrorInfo())
END
=============================================

please note that using a utility program, i can print and send a file directly to COM4. but using WMobile ,it doesn't do anything.. MAYBE SOMETHING IS MISSING?
Fabrice Harari
Re: sWrite Implementation in Windev Mobile (WM)
February 14, 2009 03:49PM
Hi Mitchell

Something is definitely missing in your code: the tests on the results of each function...

sOpen, sParameter, and so on all RETURN a value true , false, something that tells you if the function succeeded or not (see help file)...

If you do not test the result, there is no way to know what part of your code is not working

Best regards

Mitchell
Re: sWrite Implementation in Windev Mobile (WM)
February 14, 2009 04:19PM
Hi Fabrice,
I didn't get what you said, but I tried to get the value if the connection is open or not...
based on this sample code below :

Com4Line = sOpen(4, 2000, 2000)
IF Com4line = True THEN
// Configure COM4 : Rate 9600, even parity,
// 8 data bits, 1 stop bit
sParameter(4, 9600, 1, 8, 0)
// Rest of process...
sWrite(4," any text to write to the serial port") //--- this is not doing anything??
// Close COM4
sClose(4)
ELSE
Error("Error opening COM4")
END

===========================
Fabrice Harari
Re: sWrite Implementation in Windev Mobile (WM)
February 15, 2009 02:03PM
Hi Mitchell...
as I was telling you, nearly all functions return a result... In the case of sWrite, the help says:

<Result>: Integer

Number of characters written, 0 if time-out is over and if the write operation has not been performed.

So you should:
1. Check if the result of your swrite is 0 or not
2. if it's not (ie the write operation on the port succeeded, at least partially) then it'(s possible that 'nothing happens' because the printer is waiting for the remaining of the line (you are not sending any LineFeed, CR, EndOfPage or anything like that)

Best regards

Mitchell
Re: sWrite Implementation in Windev Mobile (WM)
February 15, 2009 03:23PM
hi Fabrice,

thanks a lot, My problem solved!!!!!

the only missing in my code are the LINEFEED (CRLF)

Thanks again.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: