The Comm Meta Tag is an action tag used to control the functionality of the serial port on the device, including all serial communications initiated by PocketBrowser apps and any collected or transmitted data.
Comm (META Tag) Syntax <META HTTP-Equiv="Comm" content="[parameter> <META HTTP-Equiv="Comm" content="CommEvent:url('[jsFunction | url]')">
Items listed in this section indicate methods or, in some cases, indicate parameters which will be retrieved.
Name Description
Default Value Open Opens the COM port using applied settings. Closed Close Closes the currently open COM port, if any. Closed
Copy methods template to clipboard: META Tags Javascript
Items listed in this section indicate parameters, or attributes which can be set.
Name Possible Values Description
Default Value BaudRate:[Value] 110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 56000, 57600, 115200, 128000, 256000 Sets the baud rate of the serial port. (not all values are supported on all devices) 9600 DataBits:[Value] Integers between 5 and 9 inclusive. Sets the number of data bits per word on the device serial port (not all values are supported on all devices). 8 StopBits:[Value] '1', '1.5', '2'. Sets the number of stop bits per word on the device serial port (not all values are supported on all devices). 1 Parity:[Value] 'Even', 'Odd', 'Mark', 'Space', 'No Parity' Sets the parity check type for the device serial port. (not all values are supported on all devices) 'No Parity' Handshake:[Value] 'HW' - Hardware Handshake, 'SW' - Software Handshake, 'None' - No handshake Sets the handshaking for the device serial port. (not all values are supported on all devices) 'None' Port:[Value] The device comm port, in the format COMn Sets the device serial port. (only certain port designations are valid on any given device) 'COM1' Chars:[Value] Positive number. Data will be received by PocketBrowser after the specified number of characters have been received over the COM port. PocketBrowser will receive the data in either a CommEvent or as keystrokes. 'Chars', 'EndChar' and 'Time' are mutually exclusive, see remarks. 'EndChar:CRLF' EndChar:[Value] Character code expressed as a decimal or 'CRLF' to specify Carriage return + Line Feed Data will be received by PocketBrowser after the specified character (or Carriage return + Line Feed) has been received over the COM port. PocketBrowser will receive the data, minus the final CRLF, in either a CommEvent or as keystrokes. 'Chars', 'EndChar' and 'Time' are mutually exclusive, see remarks. 'EndChar:CRLF' Time:[Value] Milliseconds Data will be received by PocketBrowser after the specified period of COM port inactivity has elapsed. PocketBrowser will receive the data in either a CommEvent or as keystrokes. 'Chars', 'EndChar' and 'Time' are mutually exclusive, see remarks. 'EndChar:CRLF' WriteBytes:[Value] A string of bytes, each byte represented as '%hh' where 'h' is a hexidecimal digit. A delimiter is optional and may be any character Value is converted to an array of bytes and written to the COM port. N/A WriteString:[Value] String Writes the specified string to the COM port. N/A WriteFile:[Value] Filename and Path The specified file is opened and its contents is written to the COM port. N/A AutoEnter:[Value] Enabled or Disabled Provided no CommEvent is defined and the received data is being received as keystrokes each block received will have a CR (Carriage Return) character appended to it. Disabled AutoTab:[Value] Enabled or Disabled Provided no CommEvent is defined and the received data is being received as keystrokes each block received will have a tab character appended to it. Disabled
Copy parameters template to clipboard: META Tags Javascript
Modules return information back to their web pages via retrieval tags, for example the scanner has a retrieval tag called 'DecodeEvent' which is called whenever it decodes a barcode. To register to receive a retrieval tag call the module as follows:
<META HTTP-Equiv="[Module]" content="[RetrievalTag]:url('[URI]')">So to register to retrieve the Scanner's DecodeEvent the following syntax would be used:<META HTTP-Equiv="Scanner" content="DecodeEvent:url('Javascript:doScan('%6', '%s', %3, '%2');')">Retrieval tags return information by replacing the text in place holders, defined as '%s' or '%<number>'. Each place holder represents 1 return value with '%s' being populated sequentially or '%<number>' providing direct acces to the desired value.
If the content for the Scanner's DecodeEvent is:
"url('Javascript:doScan('%6', '%s', %3, '%2');')"
The function would be called as follows:"Javascript:doScan('Decode', '5449000053879', 0x35, 'SCN:EAN13');"
CommEventThis event is used to read data from the COM port and is triggered in response to a port event. Port events can be one of 'Chars', 'EndChar' or 'Time' as described in the Parameters section. If no CommEvent is defined the associated data is output as keystrokes.
ID Name Description 1 Data The data that has been accumulated from the open communications port since the last time data was returned.
Copy this return value template to clipboard: META Tags Javascript
The following example opens up the COM1 port using META tags, and instructs the Comm module to call the 'ProcessData' JavaScript function after 250 ms of port inactivity, passing the received data to the function. The port will be closed when PocketBrowser navigates to a new page.
<HTML> <HEAD> <!-- Setup the port --> <META HTTP-Equiv="Comm" Content="Port:COM1"> <META HTTP-Equiv="Comm" Content="BaudRate:9600"> <META HTTP-Equiv="Comm" Content="DataBits:8"> <META HTTP-Equiv="Comm" Content="StopBits:1"> <META HTTP-Equiv="Comm" Content="Parity:'No Parity'"> <META HTTP-Equiv="Comm" Content="HandShake:None"> <META HTTP-Equiv="Comm" Content="Time:250"> <META HTTP-Equiv="Comm" Content="CommEvent:url('JavaScript:ProcessData('%s');')"> <META HTTP-Equiv="Comm" Content="Open"> <!-- Function called when data received from the port --> <SCRIPT TYPE="text/javascript"> function ProcessData(data) { alert(data); } </SCRIPT> </HEAD> <BODY> <!-- Your page goes here --> </BODY> </HTML>
Copy example to clipboard The following example sets up the communications port and opens it using JavaScript and the generic ActiveX object. This example sets the event trigger to be the receipt of the '#' character (char code = 35). The default port parameters are used. JavaScript routines for writing to the port and closing it are also included.
<HTML> <HEAD> <!-- Script that will get called on page load --> <SCRIPT TYPE="text/javascript"> var objGeneric; function DisplayData(data) { alert("Received the following data on the Comm port: " + data); } function CommSetup() { objGeneric = new ActiveXObject("PocketBrowser.Generic"); objGeneric.InvokeMETAFunction("Comm", "EndChar:35"); objGeneric.InvokeMETAFunction("Comm", "CommEvent:url('JavaScript:DisplayData('%s');'"); objGeneric.InvokeMETAFunction("Comm", "Open"); } function CommWrite() { // Write a string to the COM port objGeneric.InvokeMETAFunction("Comm", "WriteString:StringToWrite"); // Write bytes to the COM port objGeneric.InvokeMETAFunction("Comm", "WriteBytes:%62 %79 %74 %65 %20 %6d %65 %0a"); // Write a file to the COM port objGeneric.InvokeMETAFunction("Comm", "WriteFile:\\File Path\\FileToWrite.txt"); } function CommClose() { objGeneric.InvokeMETAFunction("Comm", "Close"); } </SCRIPT> </HEAD> <BODY onload="CommSetup()"> <!-- Your page goes here --> </BODY> </HTML>
Copy example to clipboard
GeneralIf any of the parameters (e.g. BaudRate) are set whilst the COM port is open they will not take effect until the port is closed and reopened again. The parameters 'Chars', 'EndChar' and 'Time' are mutually exclusive and the last one set will take priority when the COM port is next opened.AutoEnter and AccelerateKeyThe AccelerateKey Meta tag controls the behaviour of Accelerate keys on Windows CE, if the ENTER key is configured to be non-functional, then AutoEnter also will appear not to function.
Supported Platforms Windows CE, Windows Mobile Persistence This tag is mostly page persistent. However, when navigating to a new page, the port will be closed and the CommEvent cleared. RTo continue serial port communications, re-register the CommEvent and re-open the port on the new page. Min. Requirements COM Interface