Java bean to get information from serial port
we are migrating from 6i to 10g. In 6i, we used mscomm32.ocx to access to com port. Now in 10g we need a java bean. Anybody has a java bean to access to serial port or anything similar?
My email is [email protected]
Thanks in advance.
we set properties to the serial port, open the port, read (listen) from port, ... Here there are some pieces of code to you see it:
-- Si está abierto el puerto puedo leer
IF (MsCommLib_ImsComm.PortOpen(:ITEM('IF_OCX_COM').INTERFACE)=-1) THEN
-- Miro si hay caracteres
a:=MsCommLib_ImsComm.InBufferCount(:ITEM('IF_OCX_COM').INTERFACE);
IF a>0 THEN
set_item_property('COMUNICACION_ICS.ESPERA',DISPLAYED,PROPERTY_FALSE);
--Datos de un bloque nuevo, hay que insertar la fecha
IF :global.estado = 0 THEN
--Leo la fecha en la que se ha leído los datos
--SELECT SYSDATE INTO fecha
--FROM DUAL;
fecha := To_Date(:System.Current_Datetime,'dd-mon-yyyy hh24:mi:ss');
-- Borro la pantalla si hay mas de 1920 caracteres
:global.tc := :global.tc + 21;
IF :global.tc > 1920 then
:comunicacion_ics.if_txt_com_rec :='';
:global.tc := 0;
end if;
--Introduzco la fecha en el control de texto, para su posterior proceso
:comunicacion_ics.if_txt_com_rec := :comunicacion_ics.if_txt_com_rec||CHR(10)
||'__' || To_Char(fecha,'DD-MM-YYYY,HH24:Mi:SS')||chr(10);
guarda := Fichero.Escribe(:global.fic,CHR(10)||'__' || To_Char(fecha,'DD-MM-YYYY,HH24:Mi:SS')
||chr(10));
if guarda < 0 then
raise e;
end if;
END IF;
-- Indico que se están recibiendo datos de este bloque
:global.estado := 2;
--Leo la cadena
linea_ics := Var_To_Char(MsCommLib_ImsComm.Input(:item('IF_OCX_COM').INTERFACE));
linea_ics := replace(linea_ics,chr(13),CHR(10)); -- CHR(10)
--La añado al control de texto para que se vea
-- Borro la pantalla si hay mas de 1920 caracteres
:global.tc := :global.tc + a;
IF :global.tc > 1920 then
:comunicacion_ics.if_txt_com_rec :='';
:global.tc := 0;
end if;
:comunicacion_ics.if_txt_com_rec := :comunicacion_ics.if_txt_com_rec||
linea_ics;
--Escribo la linea en el fichero
-- Propiedades de Buffers
-- Tamaño del Buffer de Entrada
:prop_com.txt_in_buf := MsCommLib_ImsComm.InBufferSize(:ITEM('IF_OCX_COM').INTERFACE);
-- Tamaño del Buffer de Salida
:prop_com.txt_out_buf := MsCommLib_ImsComm.OutBufferSize(:ITEM('IF_OCX_COM').INTERFACE);
-- Tamaño de la cadena de Entrada
:prop_com.txt_input_len := MsCommLib_ImsComm.InputLen(:ITEM('IF_OCX_COM').INTERFACE);
-- RThreshold
:prop_com.txt_rthres := MsCommLib_ImsComm.RThreshold(:ITEM('IF_OCX_COM').INTERFACE);
-- SThreshold
:prop_com.txt_sthres := MsCommLib_ImsComm.SThreshold(:ITEM('IF_OCX_COM').INTERFACE);
-- EOF Enable
:prop_com.chk_eof_enable := MsCommLib_ImsComm.EOFEnable(:ITEM('IF_OCX_COM').INTERFACE);
-- Propiedades Hardware
-- Parity replace
:prop_com.txt_par_repl := MsCommLib_ImsComm.ParityReplace(:ITEM('IF_OCX_COM').INTERFACE);
-- NULL Discard
:prop_com.chk_null_discard := MsCommLib_ImsComm.NULLDiscard(:ITEM('IF_OCX_COM').INTERFACE);
-- RTS Enable
:prop_com.chk_rts := MsCommLib_ImsComm.RTSEnable(:ITEM('IF_OCX_COM').INTERFACE);
-- NULL DTR
:prop_com.chk_dtr := MsCommLib_ImsComm.DTREnable(:ITEM('IF_OCX_COM').INTERFACE);
Thanks. Inma
Similar Messages
-
Slmodem/wvdial: cannot get information for serial port
Hi,
I have the following problem when trying to set up my Intel WinModem with arch:
After configuring wvdial I get an error when trying to launch it
/dev/ttySL0: Cannot get information for serial port
Does anybody know about this problem? There is absolutely no information about it on the internet.
Thanks for any help!!!!!Hi,
I have the following problem when trying to set up my Intel WinModem with arch:
After configuring wvdial I get an error when trying to launch it
/dev/ttySL0: Cannot get information for serial port
Does anybody know about this problem? There is absolutely no information about it on the internet.
Thanks for any help!!!!! -
How to get data from serial port to GUI textArea
From Serial Port.....
Messages from base (always 5 bytes):
0xAA, 0, 0, 0, 0xBB - IDLE Mode
0xAA, 0, 0x80, 0x80, 0xBB - Question Mode
messages from terminal (always 6 bytes):
0xAA, a, b, c, chksum, 0xBB
where chksum = a+b+c;
a = address (0-250)
the 2 MSB's of b represenet the answer:
0 0 - A
0 1 - B
1 0 - C
1 1 - D
the 6LSB's of b and 8bits of c is the time for answer, in milliseconds.
(0-16384 milliseconds)
I have VB Code for that but I want the same thing in Java ...
Can any one help me?
Here's VB Code..
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Aakar GUI"
ClientHeight = 4665
ClientLeft = 60
ClientTop = 375
ClientWidth = 6105
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 311
ScaleMode = 3 'Pixel
ScaleWidth = 407
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdPort
Caption = "Open Port"
Height = 375
Left = 120
TabIndex = 4
Top = 600
Width = 1455
End
Begin VB.ComboBox cmbPort
Height = 315
ItemData = "Form1.frx":0000
Left = 120
List = "Form1.frx":0016
Style = 2 'Dropdown List
TabIndex = 3
Top = 120
Width = 2895
End
Begin VB.CommandButton cmdEnd
Caption = "End"
Height = 495
Left = 1560
TabIndex = 2
Top = 1320
Width = 1215
End
Begin VB.CommandButton cmdStart
Caption = "Start"
Height = 495
Left = 120
TabIndex = 1
Top = 1320
Width = 1215
End
Begin VB.TextBox txtMessage
Height = 2040
Left = 119
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 0
Top = 2475
Width = 5848
End
Begin VB.Timer tmrRead
Enabled = 0 'False
Interval = 1
Left = 2040
Top = 600
End
Begin MSCommLib.MSComm MSComm1
Left = 3120
Top = 360
_ExtentX = 1164
_ExtentY = 1164
_Version = 393216
DTREnable = 0 'False
ParityReplace = 45
SThreshold = 1
End
Begin VB.Label Label5
Caption = "Result Data:"
Height = 375
Left = 120
TabIndex = 5
Top = 2115
Width = 1320
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim PortIsOpen As Boolean
Dim Answers(4) As String
Dim RejectKeystroke As Boolean
Private Sub cmbPort_Change()
Debug.Print cmbPort.ListIndex
End Sub
Private Sub cmbPort_Validate(Cancel As Boolean)
'Cancel = True
End Sub
Private Sub cmdEnd_Click()
MSComm1.Output = "e"
txtMessage.Text = ""
End Sub
Private Sub cmdPort_Click()
On Error GoTo ErrorHandler
If cmbPort.ListIndex < 0 Then Exit Sub
If PortIsOpen Then
cmbPort.Enabled = True
MSComm1.PortOpen = False
PortIsOpen = False
cmdPort.Caption = "Open Port"
cmdStart.Enabled = False
cmdEnd.Enabled = False
Else
MSComm1.CommPort = cmbPort.ListIndex + 1
cmbPort.Enabled = False
MSComm1.PortOpen = True
PortIsOpen = True
cmdPort.Caption = "Close Port"
cmdStart.Enabled = True
cmdEnd.Enabled = True
End If
Exit Sub
ErrorHandler:
Debug.Print Err.Number
Debug.Print Err.Description
MsgBox Err.Description, vbExclamation Or vbOKOnly, "Error opening port"
cmbPort.Enabled = True
PortIsOpen = False
cmdPort.Caption = "Open Port"
cmdStart.Enabled = False
cmdEnd.Enabled = False
End Sub
Private Sub cmdStart_Click()
MSComm1.Output = "s"
txtMessage.Text = ""
End Sub
Private Sub Form_Initialize()
Dim tmp As Variant
tmp = InitCommonControls
End Sub
Private Sub Form_Load()
Answers(0) = "A"
Answers(1) = "B"
Answers(2) = "C"
Answers(3) = "D"
'MSComm1.Settings = "9600,n,8,1"
''MSComm1.Settings = "115200,n,8,1"
'MSComm1.PortOpen = True
On Error GoTo ErrorHandler1
MSComm1.CommPort = 1 ' comm port 1
MSComm1.RThreshold = 1 ' use 'on comm' event processing
MSComm1.Settings = "9600,n,8,1" ' baud, parity, data bits, stop bits
MSComm1.SThreshold = 1 ' allows us to track Tx LED
MSComm1.InputMode = comInputModeText 'comInputModeBinary ' binary mode, you can also use
' comInputModeText for text only use
PortIsOpen = False
cmbPort.ListIndex = 0
' open the port
MSComm1.PortOpen = True
cmbPort.Enabled = False
PortIsOpen = True
cmdPort.Caption = "Close Port"
cmdStart.Enabled = True
cmdEnd.Enabled = True
Exit Sub
ErrorHandler1:
Debug.Print Err.Description
PortIsOpen = False
cmbPort.Enabled = True
cmdPort.Caption = "Open Port"
cmdStart.Enabled = False
cmdEnd.Enabled = False
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If MSComm1.PortOpen Then MSComm1.PortOpen = False
End Sub
Private Sub lblOption_Click()
End Sub
Private Sub MSComm1_OnComm()
' Synopsis: Handle incoming characters, 'On Comm' Event
' Description: By setting MSComm1.RThreshold = 1, this event will fire for
' each character that arrives in the comm controls input buffer.
' Set MSComm1.RThreshold = 0 if you want to poll the control
' yourself, either via a TImer or within program execution loop.
' In most cases, OnComm Event processing shown here is the prefered
' method of processing incoming characters.
Dim i As Long
Dim sBuff As String ' buffer for holding incoming characters
Const MTC As String = vbCrLf ' message terminator characters (ususally vbCrLf)
Const LenMTC As Long = 2 ' number of terminator characters, must match MTC
Dim iPtr As Long ' pointer to terminatior character
' OnComm fires for multiple Events
' so get the Event ID & process
Select Case MSComm1.CommEvent
' Received RThreshold # of chars, in our case 1.
Case comEvReceive
' read all of the characters from the input buffer
' StrConv() is required when using MSComm in binary mode,
' if you set MSComm1.InputMode = comInputModeText, it's not required
'sBuff = sBuff & StrConv(MSComm1.Input, vbUnicode)
'If Len(txtMessage.Text) > 4096 Then txtMessage.Text = ""
sBuff = MSComm1.Input
Dim ch As String
Dim PacketStart As Boolean
Dim PacketLength As Integer
Dim Packet() As String
PacketStart = False
PacketLength = 0
While (Len(sBuff) > 0)
ch = Left(sBuff, 1)
If (ch = Chr(&HAA)) Then PacketStart = True
If (ch = Chr(&HBB)) Then PacketStart = False
If (ch <> Chr(&HAA) And ch <> Chr(&HBB)) Then
PacketLength = PacketLength + 1
ReDim Preserve Packet(PacketLength)
Packet(PacketLength) = ch
End If
'txtMessage.Text = txtMessage.Text + Format(Hex(Asc(ch)), " @@")
sBuff = Right(sBuff, Len(sBuff) - 1)
Wend
If (PacketLength = 3) Then
Debug.Print "Command packet recieved"
'txtMessage.Text = txtMessage.Text + vbCrLf + "Address =" + Str(Asc(Packet(1)))
'txtMessage.Text = txtMessage.Text + vbCrLf + "Address =" + Str(Asc(Packet(2)))
End If
If (PacketLength = 4) Then
Debug.Print "Response packet recieved"
txtMessage.Text = txtMessage.Text + "Address =" + Str(Asc(Packet(1))) + _
" Answer = " + Answers((Asc(Packet(2)) And &HC0) / 64) + _
" Time =" + Str((Asc(Packet(2)) And &H3F) * 256 + (Asc(Packet(3)))) + "mS" + vbCrLf
'txtMessage.Text = txtMessage.Text + vbCrLf + "Address =" + Str(Asc(Packet(1)))
'txtMessage.Text = txtMessage.Text + vbCrLf + "Option =" + Str((Asc(Packet(2)) And &HC0) / 64)
'txtMessage.Text = txtMessage.Text + vbCrLf + "Time =" + Str((Asc(Packet(2)) And &H3F) * 256 + (Asc(Packet(3))))
End If
If (PacketLength <> 4 And PacketLength <> 3) Then Debug.Print "Unknown packet of length" + Str(PacketLength) + " recieved"
txtMessage.Text = txtMessage.Text + vbCrLf
' An EOF charater was found in the input stream
Case comEvEOF
DoEvents
' There are SThreshold number of characters in the transmit buffer.
Case comEvSend
DoEvents
' A Break was received.
Case comEventBreak
DoEvents
' Framing Error
Case comEventFrame
DoEvents
' Data Lost.
Case comEventOverrun
DoEvents
' Receive buffer overflow.
Case comEventRxOver
DoEvents
' Parity Error.
Case comEventRxParity
DoEvents
' Transmit buffer full.
Case comEventTxFull
' Unexpected error retrieving DCB]
Case comEventDCB
DoEvents
End Select
End Sub
Private Sub tmrRead_Timer()
'MSComm1.Output = vbCrLf + vbCrLf
'MSComm1.Output = Chr(128)
End Sub
Private Sub txtMessage_KeyDown(KeyCode As Integer, Shift As Integer)
If Shift = 2 Or Shift = 4 Then RejectKeystroke = False Else RejectKeystroke = True
End Sub
Private Sub txtMessage_KeyPress(KeyAscii As Integer)
If RejectKeystroke Then
KeyAscii = 0
End If
End SubThanks in advance..I want to replicate the entire VB program as Java Program.
This has to be included in my project which i am doing in java. -
Java program to receive byte from serial port
hello everyone, i am recently working one a project which require communication between pic16f877 and PC. My pic continuiously measure a voltage and send the result (a byte ranging from 0 to 255) to the rs232 port. One the pc side, my java program keep reading the serial port and it works for values 0~127 and 160~255. But if the byte value is between 127 and 160, it cannot received correctly, i get something like 375,8224,or even 65532 etc(no obvious path but more likely to be 300+,700+,8000+ or 65500+). I have been trying very hard to solve this and i think the problem is due to the pc software. I am feeling so frustrated and any suggestion will be much appreciated.
p.s. : i used Bufferedreader.read() in my program
--mengyaofumengyao wrote:
hello everyone, i am recently working one a project which require communication between pic16f877 and PC. My pic continuiously measure a voltage and send the result (a byte ranging from 0 to 255) to the rs232 port. One the pc side, my java program keep reading the serial port and it works for values 0~127 and 160~255. But if the byte value is between 127 and 160, it cannot received correctly, i get something like 375,8224,or even 65532 etc(no obvious path but more likely to be 300+,700+,8000+ or 65500+). I have been trying very hard to solve this and i think the problem is due to the pc software. I am feeling so frustrated and any suggestion will be much appreciated.
p.s. : i used Bufferedreader.read() in my program
--mengyaothis may not matter in your case - but don't use a Reader, use a Stream (BufferedInputStream maybe) -
JMF getting data from tcp port
Hi there is any way that i can get data from tcp port uisng datasourece
mean i create a server port which accept the connection after established the connection then the client send audio data to the server, the server only will get that data in a buffer and using jmf datasource i should read that data and might send it to another machine using avtransmitter but i dont know how to wrape that data in rtp
private void Streamforward()
ServerSocket echoServer = null;
byte[] buffer=new byte[8192];
DataInputStream is;
PrintStream os;
Socket clientSocket = null;
// Try to open a server socket on port 4444
// Note that we can't choose a port less than 1023 if we are not
// privileged users (root)
try {
echoServer = new ServerSocket(4444);
catch (IOException e) {
System.out.println(e);
// Create a socket object from the ServerSocket to listen and accept
// connections.
// Open input and output streams
try {
clientSocket = echoServer.accept();
Convert con=new Convert();
is = new DataInputStream(clientSocket.getInputStream());
os = new PrintStream(clientSocket.getOutputStream());
int start=0;
while (true)
int length=clientSocket.getReceiveBufferSize();
System.out.println(length);
//line=in.readLine();
is.read(buffer,0,length);
//here we should put that data into datasourece
catch (IOException e) {
System.out.println(e);
it would be too help full i have to submitt my project soon and i dont know what to do:( with this data ....i am integratting skype with jmfI've been looking around for the same solution for my client (who using Mettler Toledo's (MT) products). Anyone did this please kindly share your experience, thanks.
My initial approach was to write a Java middle-ware to read from the real-time system and upload into JDE from there.
I wonder if MT stored the weighing data somewhere in some database ...
Any other hardware vendor out there to make our life easier?
Additional:
Just got a way that might work, use Java or JNI to read from Serial port (RS-232) or USB, then proceed from there (provided your hardware with that communication protocol).
Cheers,
Avatar Ng
Edited by: user2367131 on Aug 18, 2009 6:34 AM -
Get information from an array saved into a text file
I am trying to get information from an array saved as a text file to extract the information to build an string. This string will go out from the serial port to a device which will listen this message and it will answer the question. All the information sended sequencially it has to be obtained from that array. Every row contain one instruction and this has to be sended one after one.
Could you tell me if is possible to make this driver? And if you have a similar driver, Where can I get it from?The VIs that I would suggest using are found in the String Function Pallet:
Spreadsheet String To Array
Array To Spreadsheet String
The delimiter should be the termination character. These VIs will adapt to a string array.
For the Spreadsheet String To Array wire an empty string array and use %s as the format. The delimiter should be the termination character of the text file, most likely a end of line (\r\n).
For the Array To Spreadsheet String the delimiter should be the termination required for your serial device.
Using a combination of these two VIs should provide you the functions required to make the driver. -
How to save a datas from serial port?
How to save a datas from serial port?
Hi
I need some help about rs-232 communication. I want to make a vi witch can do this things:
-read a txt file (to simulate a serial port like when the datas are coming)
i will get 3 different data in serial port (like this: 121 213 135)
i want to save in a txt file what datas get my vi
so
-write in a txt file or draw in a diagram (or both)
so my problem is: read in serial port and save in a file and draw a diagram.
if anybody can help pls HELP ME because im a beginner in this problem.
I already do something but Im not sure that good.
Thx for all. -
When getting information from SLD, should SMSY create a system for EP?
I've connected my EP NW2004s system ES3 to the SLD. I connected Solution Manager 4.0 to SLD so that SMSY can get information from the SLD. When I run the import, I see:
1. ES3's server sapeps03 created under SMSY Landscape Component ->Server.
2. ES3 's database ES3 created under SMSY Landscape Component-> Database.
3. ES3 Java component entry created under SMSY Landscape Component->System Components->Java System.
BUT, I don't see an ES3 entry under SMSY Landscape Component->Systems->SAP Netweaver. Shouldn't there be? Do I have to create this manually?
The ECC 5.0 system RS3 got created under SMSY Landscape Component->Systems->SAP ECC. Why not the EP system?
Thanks.
Regards,
Mel CalucinHello Mel,
the SMSY transaction had a lot of issues resolving the appropriate Java product with older versions of Solution Manager. For instance, you can take a look at the SAP Note 1392992.
Newer versions of Solution Manager (currently on SP24) resolve most of the issues. The portal is certainly detected successfully.
My recommendation would be having Solution Manager updated always with the latest Support Package stack available.
All the best,
Andreu -
Read data from serial port or TCP port of frontend PC
Hello Friends,
I have requirement to read data from device connected to frontend PC which will provide meter reading data.
Vendor has given me two option.
1. Device can be connected to seiral port and data transfer will be done through MODBUS RTU protocol.In that case data need to capture from serial port.
2. Device can be connected to TCP port and Socket program can be provided for data transfer. In that case SAP will act as client and communicate with TCP port.
There will be multiple workstation with individual meters connected to them.
I am aware of text file interfacing through front end tools using custom code using VB,JAVA or others.
Is there any solution availble to achieve above things using ABAP other than text file , like direct communication?
I am using ECC 6.0.Hello,
Socket programming in not available on ABAP, but you may use RFC for the same.
Use the below links for more details
[Link 1|http://help.sap.com/printdocu/core/print46c/en/data/pdf/BCFESDE2/BCFESDE2.pdf]
[Link 2|http://forums.sdn.sap.com/thread.jspa?threadID=1820233]
Regards,
Abhishek -
Problem while reading data from Serial Port
Hi All,
I am facing some problem while reading data from Serial Port.
As per the requirement I am writing the data on Serial Port and waiting for response of that data.
Notification for data availabilty is checked with method public void serialEvent(SerialPortEvent event) of javax.comm.SerialPortEventListener.
When we are writing data on the port one thread i.e. "main" thread is generated and when data availability event occures another thread "Win32SerialPort Notification thread" is generated. This creates problem for me as we can't control thread processing.
So can anybody pls explain me how to overcome this problem?
Regards,
NehaMy Problem is:-
I am simoultaneouly wrting data on port & reading data from port.
First I write data on port using outputStream.write() method. Now when target side sends me response back for the request on serial port DATA_AVAILABLE of SerialPortEventListner event occured,we are reading data from serial port.Now till the time we didn't get the response from target next command can't be written on the serial port. When we are writing data on port main thread is executed.Now my problem starts when DATA_AVAILABLE event occured.At this point another thread is created.Due to this my program writes data of next command without reading response of previous command.To solve this prob. I have used wait() & notify() methods as follows.But again due to this my pc hangs after execution of 2 commands. (PC hang in while loop in a code provided below.)
From SOPs I could figure it out that after 2 commands we are not able to write data on serial port so DATA_AVAILABLE event doesn't occure n pro. goes in wait state.
Can anybody help me to solve this issue.
Neha.
Code:
public void serialEvent(SerialPortEvent event)
switch (event.getEventType())
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
try
dataThread = Thread.currentThread();
dataThread.setPriority(10);
dataAvailable = true;
byte[] tempArray=new byte[availableBytes];
inputStream.read(tempArray);
catch (IOException io)
SOP(io, "Error in serialEvent callback call for event DATA_AVAILABLE");
public void writetoPort(byte[] data) throws IOException
outputStream.write(data);
while(finalTimeOut >= actualTime)
if( ! dataAvailable)
actualTime = System.currentTimeMillis();
else
synchronized (mainThread)
mainThread = Thread.currentThread();
mainThread.wait();
public void sendDatatoUser(byte[] b) throws Exception, HWCCSystemFailure
obj.returnData(b);
synchronized(mainThread)
mainThread.notify();
-
Reading a char array from Serial port
Need help!
Hi, I've got the following problem - I wanna read a input stream from serial port and I use at the moment the following method (reading bytewise):
public String receiveText (){
byte ch;
fStrBuf.delete(0,fStrBuf.length()); //clearing the buffer
try{
do {
ch = (byte) fPortInStream.read();
fStrBuf.append( (char) ch);
while ( (byte) ch != 0x03); //The end of frame byte
}catch(IOException ioe) {};
return fStrBuf.toString();It works pretty well, but disadvantage is that it's too slow to use it in the thread (at least I think so)
How can I change it to read all available data from the port (or simply faste). I don't need event listeners, because it's a request-responde communication.
I tried smth. like this
byte[] readBuffer = new byte[20];
try {
while (fPortInStream.available() > 0) {
int numBytes = inputStream.read(readBuffer);
fStrBuf.append(readBuffer);
} catch (IOException e) {}
return fStrBuf.toString();But it doesn't seem to work :-(May I suggest that you use StringBuilder rather than StringBuffer. It has less overhead because it is not threadsafe. I do synchronous serial port stuff with Opto 22, and i have no listeners enabled.
Appending to the String(Builder/Buffer) directly from the byte buffer mangles it. So I use a string (ugh). With the Opto22 brain boards, i am looking for a carriage return as a term char. It either finds it or times out.
This is the best i have come up with so far:
StringBuilder response = new StringBuilder();
String data = new String();
long msTimeOut = 2000;
public void getResponse () throws IOException {
byte[] readBuff = {0};
int charAvail;
response.delete(0,response.length());
long ts = Calendar.getInstance().getTimeInMillis();
try {
while ( readBuff[readBuff.length-1] != '\r' ) {
charAvail = inputStream.available();
if ( charAvail > 0 ) {
readBuff = new byte[charAvail];
inputStream.read(readBuff);
response.append(new String(readBuff));
if ( Calendar.getInstance().getTimeInMillis() > (ts + msTimeOut) ) {
response.delete(0,response.length());
response.append("TIMEOUT");
break;
} catch (IOException e) { e.printStackTrace(); throw e; }
data = response.substring(0);
} I just starting writing Java about 4 days ago, so caveat emptor. -
Count time between 2 readings from serial port... help!.
Hi guys,
I am using my application to get the readings sent by microcontroller from serial port. It works perfectly. But i have the problem, the pic uses 16bits counter, and sometimes i measure frequency lower than 15hz (65535-->16bits). Thats why I thought to measure the time between each pulse that it recieved in serial port. So i could multiply the reading about the time which spend in arrive to serial port. I know if any pulse spend more than 15hz, i should add 65535 to this reading.
Then, the idea is count the time spent between each reading in serial port. SInce pics count and later send each turn.
I dont know if it is possible, and exist any easy way.. Can ayone help me?.
I would like to see any example of it, always it is possible.
Regards, Fonsi.
Attachments:
capture.GIF 19 KBYou're not going to be able to get even close to 1 usec resolution using the built-in time functions though I don't see any of those in your attachment. The windows clock is simply not that accurate. If you need to precisely time your serial reads you might want to look at using the timed loop. You can set the period of that to 1 msec.
-
Question for get information from https site with socket.
I had tried to send a HTTP request with socket like :
POST http://xxx.xxx..xxx/bbs/bbsadd.php?blockid=119&title=Hello&content=Hello&clid=101&Ok=OK&s_no=0&mood=1 HTTP/1.0\r\n\r\n"
Just like this way , I could get some information or submit any message to http site like that .
But that was not success to get some information for visited https ( like Yahoo ) use the same way .
I had read some document about the https protocl I knew that had to need SSL for validate .
But what should I do as a socket program ?
package sailing;
import java.net.*;
import javax.net.ssl.*;
import java.io.*;
public class ReceiveMail
//private Socket toYahoo;
private SSLSocket toYahoo;
private SSLSocketFactory factory;
private BufferedReader read;
private DataOutputStream write;
private String login;
public ReceiveMail(String userName,String userPassword)
try
//this.toYahoo=new Socket("202.43.216.165",80);
this.factory=(SSLSocketFactory)SSLSocketFactory.getDefault();
this.toYahoo=(SSLSocket)this.factory.createSocket("202.43.216.165",443);
//this.login="POST https://edit.bjs.yahoo.com/config/login?.src=ym&login="+userName+"&passwd="+userPassword+" HTTP/1.0\r\n\r\n";
this.login="POST https://edit.bjs.yahoo.com/config/login?.src=ym&login="+userName+"&passwd="+userPassword+" HTTP/1.0\r\n\r\n";
byte[] makeBytes=this.login.getBytes();
this.write=new DataOutputStream(this.toYahoo.getOutputStream());
this.write.write(makeBytes,0,makeBytes.length);
this.write.flush();
this.read=new BufferedReader(new InputStreamReader(this.toYahoo.getInputStream()));
String readRes="";
String webFileCode="";
while((readRes=this.read.readLine())!=null)
webFileCode+=readRes;
System.out.println(webFileCode);
catch(IOException e)
System.out.println(e);
public static void main(String args[])
new ReceiveMail("sailing","sailing");
}================================
If this program perform successful , I think it will print code that login Yahoo Mail success .
But I just could get an error code .................
Why?Hi,
According to your post, my understanding is that you wanted to get information from multiple lists once a user was selected.
There is no out of the box way to accomplish this with SharePoint.
As a workaround, I recommend to create a list to store the user names. Then you can create relationships between lists using the browser UI. Once you select the user name in the parent list, the associated items will be displayed in the child lists.
Here are two great articles for you to take a look at:
http://office.microsoft.com/en-in/sharepoint-server-help/create-list-relationships-by-using-unique-and-lookup-columns-HA101729901.aspx#_Toc270607416
http://msdn.microsoft.com/en-us/library/ff394632.aspx
Best Regards,
Linda Li
Linda Li
TechNet Community Support -
Unable to capture data from Serial port using LVRT2010 in single core pentium 4 machine
I am using application written in Labview using windows Labview
Runtime environment 2010. Application creates a tunnel to intercept data from
Serial port.
My problem is, Currently, I am using single core Pentium
processor. When I am trying to intercept the data between COM1 and COM7 (COM 7
is a virtual port) it is not able to capture data.
When I am running Labview RT environment using dual core
processor machine it is running normally. I wonder whether it could be the compatibility issues with
single core Pentium processor.Hi Magnetica
Are both of the machines running the same runtime engine,
drivers ect?
Have you had RT applications running on this
machine before?
Is the development computer a 64bit machine?
The processor is a supported model (See link below).
http://zone.ni.com/devzone/cda/tut/p/id/8239
Regards
Robert
National Instruments UK & Ireland -
Over a week ago I updated my computer to Firefox 4.0. Since then my computer is very slow accessing the internet, websites and getting information from within a website. Also, a tool bar has shown up for YAHOO which I did not request. The old detailed tool bar for Firefox has disappeared. All that now shows for Firefox is the area to enter website urls and an area to enter topic for a Google Search.
Many times I have to exit Firefox and re-enter it later to access the internet.
Please advice what I need to do to get back to the speed I had with the older version of Firefox.
Thank You,
DennisOver a week ago I updated my computer to Firefox 4.0. Since then my computer is very slow accessing the internet, websites and getting information from within a website. Also, a tool bar has shown up for YAHOO which I did not request. The old detailed tool bar for Firefox has disappeared. All that now shows for Firefox is the area to enter website urls and an area to enter topic for a Google Search.
Many times I have to exit Firefox and re-enter it later to access the internet.
Please advice what I need to do to get back to the speed I had with the older version of Firefox.
Thank You,
Dennis
Maybe you are looking for
-
Help with Enterprise Manager v9.2
While using Enterprise Manager console (with Windows XP), I have experienced abrupt termination by the Client/Console when I try to view tables within the Schema section (by clicking on a table name)...it just closes on screen before my eyes. This do
-
Problem with NW04s SR2 installation with MS SQL Server 2000 SP4
Im struggling with the NW04s installation with MS SQL Server 2000. The installation stops at the step Create/modify database schema SAPJ2EDB. The following error/info from log file, INFO 2007-06-06 12:02:33 [iaxxgenimp.cpp:632] sh
-
Finally some updates have been released. But there's one problem: where can find any info about those updates??? nothing appears when I download them in Creator, nothing on Sun pages! I only know that it is a fix for design and run-time modules...
-
Macbook Pro Fuzzy Green Screen & Won't Install Mavericks
Hello I've had my Macbook Pro 15 Inch since late 2011 and recently i've been getting this Green Screen that fuzz's & shows up randomally, so i uninstalled Mavericks and tried to reinstall it ever since i'd been having this problem. It won't reinstall
-
IIS ARR 3.0 does not have route to server farm options.
Hi Support, I have downloaded IIS AAR 3.0 and install it on Windows 2008 server. After that, I proceed to create server farm and added few CAS servers. Then I go to URL rewrite and under Action->Action Type on the dropdown box, I can't seem to find