Info about read or write a serial port with forms 6.0.5
Anybody can give some info. on read or write a serial port using form (Developer 6.0.5).
Thanks
MM
null
One option you can try is to develop a DLL
function to read/write serial port,
and then write a ORA_FFI procedure to call the DLL function.
Peter Ng
Calgary, Canada
null
Similar Messages
-
Serial communication with forms developer
How I can send character to a serial port with form developer 6.0 on winNT 4.0?
Thank you, P. Guerriero.If you're using a serial connection can you talk to it using HyperTerminal, or equivalent serial communication program? You should check this first.
More than likely the issue is with termination characters. Check the documentation to determine what termination characters need to be used when sending commands, and what termination characters are used to indicate the end fo a read. For commands it's usually just a carriage return, and for reading data it's usually a linefeed. -
Write to Serial Port without splitting string data
Hi, all, thank you for your help in advance.
Problem:
I am trying to write to the serial port with VISA write module. Somehow the string I tried to send was splitted before it was sent. For example, if I want to send "127", it sends "7', "2", "1". I don't know if there's anyway to configure the module so that it sends out the whole string at once. I use the return count to indicate how many times it spits the data. So "127" now returns "3" (sent three times. I would like to have it to return "1" so that "127" was sent in whole).
Project:
I am working on an application where a DC motor is controlled by a controller talking to the PC's serial port. "127" stands for its maximum power. The controller devides the power into 128 steps. Therefore I need to input number from 0 to 127 to command the speed.
Any help or suggestion will be appreciated!Thanks for the prompt replies.
About Number/ASCII
I am using the Atmega128-Controller Chip to read in the signals sent from the computer serial port. Then it sends signals to the motor controller. The Atmega chip reads the ASCII string and converts it to hexadecimal number, sending that number to the motor controller. I can program the Atmega chip so that it either translates the ASCII string into hex as mentioned or accepts as it is. Either way, I want it to read two byte information at once (00 to 7F).
If the VISA serial write can send only one byte at a time, then I may have to program the chip so that it buffers the readings. I have tried using number/hex converter and number/string converter, either case, the fact that VISA Write spits one byte at a time hinders the programming. For example: I defined numbers 1 to 5 represents 20% to 100% power output with 20% increment Then I defined "10" as "90%" power, but it reads "1" "0" seperately, so the actual out put is "20%" then "0%".
I used the example VI provided by NI : advanced serial write/read. For convenience, attached here. Not all modification I made is saved. -
Problems reading the serial port with labview 5.1.
I open the example serial.vi , I select write to serial port, run the programm, I don`t have any problem. But when I select read serial port, I get the error code 16392and hex code error x4008. I need to know what can I do? Thanks a lot
Any time you get an error in LV you can right click on the error cluster indicator and do a "Explain Error".
If you do this for the error code you reported, the explanation says that it was a framing error.
In serial communications, a framing error indicates that the hardware was not able to detect a start bit, data then the stop bits that comprise a frame.
This prompts me to suggest that you check you port setting on the serial port. You want to make sure you are setting the port for the correct;
Number of start/stop bits,
Baud rate
data bits
parity (just for good measure)
and hardware handshaking.
I hope this helps,
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction -
Write to serial port and digital port at the same time
hello,
I need to write to the digital port and the serial port at the same time. Right now I have the two vi's (to write to the serial port, write to the digital port) in the sequence structure. First I write the digital port, then write the serial port. Using the oscilloscope, the interval between these two executions is 10 ms; and I need to reduce this interval to as small as possible. I would appreciate help in any way. Thank you.Hello;
This is a little tricky. Since the transition from one sequence to another is completely Software timed, and windows manages all tasks that are running at one given time, there isn't a method to reduce that transition time.
The most you can do is try to optimize your code so all the time expent on the transition is due only to the task management.
Hope this helps.
Filipe A.
Applications Engineer
National Instruments -
why does a standalone program created in Labview 8.5 try connecting to the internet when the program only reads data through the serial port? Firewalls object to progams that contact the internet without permission.
The created program is not performing a command I have written when it tries to connect to the internet, it must be Labview that is doing it. How do I stop this from happening?
Any help would be very appreciated.It looks that way..
"When LabVIEW starts it contacts the service
locator to removes all services for itself. This request is triggering
the firewall.This is done in case there were services that were not
unregistered the last time LabVIEW executed- for example from VIs that
didn't clean up after themselves"
This is not yet fixed in LV2009.
Message Edited by Ray.R on 11-04-2009 12:25 PM -
How can I have both functions "Read Only" & "Write" mode on the same form?
Dear all,
How can I have both functions "Read Only" & "Write" mode on the same form? Is it possibile for this?
Please advice,
AmyThis is what I use in some dialogs:
PROCEDURE SET_QUERY_ONLY IS
-- Procedure Set_query_only
-- Rend les blocks non modifiables --
-- Disable menus Insert/Delete/Clear --
-- Entree :
-- Sortie :
-- Ent/Sortie :
-- Creation : FD 10/2003
-- Modification :
LC$Block Varchar2(30) ;
BEGIN
Set_Menu_Item_Property('Edit.Insert', ENABLED, PROPERTY_FALSE ) ;
Set_Menu_Item_Property('Edit.Remove', ENABLED, PROPERTY_FALSE ) ;
Set_Menu_Item_Property('Edit.Clear', ENABLED, PROPERTY_FALSE ) ;
Set_Menu_Item_Property('Action.Save', ENABLED, PROPERTY_FALSE ) ;
LC$Block := get_form_property( NAME_IN('System.Current_Form'), FIRST_BLOCK ) ;
-- Tous les blocs en Query only --
While LC$Block is not null Loop
Enable_Block( LC$Block, FALSE ) ;
LC$Block := get_block_property( LC$Block, NEXTBLOCK ) ;
End loop ;
END;
PROCEDURE ENABLE_BLOCK
PC$Block in Varchar2,
PB$Enable in Boolean Default TRUE
) IS
-- Procedure Enable_block
-- Rend le bloc Enable / Disable --
-- Entree : PC$Block (nom du bloc Forms)
-- : PB$Enable (TRUE ou FALSE)
-- Sortie :
-- Ent/Sortie :
-- Creation : FD 10/2003
-- Modification :
BEGIN
If PB$Enable Then
Set_Block_Property( PC$Block, INSERT_ALLOWED, PROPERTY_TRUE ) ;
Set_Block_Property( PC$Block, UPDATE_ALLOWED, PROPERTY_TRUE ) ;
Set_Block_Property( PC$Block, DELETE_ALLOWED, PROPERTY_TRUE ) ;
Set_Menu_Item_Property('Edit.Insert', ENABLED, PROPERTY_TRUE ) ;
Set_Menu_Item_Property('Edit.Remove', ENABLED, PROPERTY_TRUE ) ;
Set_Menu_Item_Property('Edit.Clear', ENABLED, PROPERTY_TRUE ) ;
Set_Menu_Item_Property('Action.Save', ENABLED, PROPERTY_TRUE ) ;
Else
Set_Block_Property( PC$Block, INSERT_ALLOWED, PROPERTY_FALSE ) ;
Set_Block_Property( PC$Block, UPDATE_ALLOWED, PROPERTY_FALSE ) ;
Set_Block_Property( PC$Block, DELETE_ALLOWED, PROPERTY_FALSE ) ;
Set_Menu_Item_Property('Edit.Insert', ENABLED, PROPERTY_FALSE ) ;
Set_Menu_Item_Property('Edit.Remove', ENABLED, PROPERTY_FALSE ) ;
Set_Menu_Item_Property('Edit.Clear', ENABLED, PROPERTY_FALSE ) ;
Set_Menu_Item_Property('Action.Save', ENABLED, PROPERTY_FALSE ) ;
End if ;
END;Francois -
Write to serial port asyncronously
I am trying to write a commands to a serial port but my problem is that the operation is tedious so it is freezing up my UI. What makes it more complicated is that I must call this procedure when the form loads I want to ask if anyone can provide an alternative
way to get the same or better result I was thinking of running it asynchronously but I don't know how to?
This is the code I am calling on load
If lblConnected.Text = "" Then
MsgBox("Please connect to port.", MsgBoxStyle.OkOnly, "Validation")
Exit Sub
End If
RichTextBox1.Text = ""
Try
With SerialPort1
rcvdata = ""
.Write("AT" & vbCrLf)
Threading.Thread.Sleep(1)
.Write("AT+CMGF=1" & vbCrLf)
Threading.Thread.Sleep(1)
.Write("AT+CPMS=""SM""" & vbCrLf)
Threading.Thread.Sleep(1)
.Write("AT+CMGL=""ALL""" & vbCrLf)
Threading.Thread.Sleep(1)
.Write("AT+CNUM" & vbCrLf)
Threading.Thread.Sleep(2000)
Dim lineoftext As String
Dim arytextfile() As String
Dim myString As String
lineoftext = rcvdata.ToString
arytextfile = Split(lineoftext, "Your number is", CompareMethod.Text)
myString = "Your number is"
lineoftext = lineoftext.Substring(lineoftext.IndexOf("Your number is"), 40)
lineoftext = lineoftext.Replace("Your number is", "")
lineoftext = lineoftext.Substring(0, 13)
txtDonglePhoneNumber.Text = LTrim(lineoftext)
End With
Catch ex As Exception
MsgBox(ex.Message)
End Try
I am trying to extract the phone number from this whole routine and it works but its freezing up my UI. How can I run from another thread.
If you think it you can achieve itImports System.IO.Ports
Imports System.Threading
Public Class Form1
Private comport As SerialPort
Private sending As Boolean
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
sending = False
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
comport = CreateComport(comport)
If sending = False AndAlso OpenComport(comport) = True Then
Dim t As Threading.Thread = New Threading.Thread(AddressOf SendData)
t.IsBackground = True
t.Start(comport)
End If
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
CloseComport(comport)
End Sub
Private Function CreateComport(ByVal port As SerialPort) As SerialPort
If port Is Nothing Then
port = New SerialPort("COM4", 9600, Parity.None, 8, StopBits.One)
End If
Return port
End Function
Private Function OpenComport(ByVal port As SerialPort) As Boolean
Try
If (Not port Is Nothing) AndAlso (port.IsOpen = False) Then
port.Open()
End If
Return True
Catch ex As Exception
MessageBox.Show(String.Format("Exception :{0}", ex.ToString()))
Return False
End Try
End Function
Private Sub CloseComport(ByVal port As SerialPort)
Try
If (sending = False) AndAlso (Not port Is Nothing) AndAlso (port.IsOpen) Then
port.Close()
MessageBox.Show("Port closed")
End If
Catch ex As Exception
MessageBox.Show(String.Format("Exception :{0}", ex.ToString()))
End Try
End Sub
Private Sub SendData(ByVal port As Object)
Dim buffer(1023) As Byte
For i As Int32 = 0 To buffer.Length - 1
buffer(i) = i Mod 256
Next
sending = True
Try
DirectCast(port, SerialPort).Write(buffer, 0, buffer.Length)
Catch ex As Exception
CloseComport(DirectCast(port, SerialPort))
MessageBox.Show(String.Format("Exception :{0}", ex.ToString()))
Finally
sending = False
End Try
End Sub
End Class
在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。 -
Hi,
I am using jdk 1.3.1, forte ce 3.0 and j2me 1.0.3 beta.
I wrote a midlet that should write and read strings to and from the serial port.
Using the Emulator I have the reading working, but the writing freezes the execution.
Any ideas?
DebbieThanx for your reply (I have been asking this question everywhere for 2 weeks and no one has answered...).
I am using the Motorola i85s. It is specifially stated in the "i85s & i50sx Release 2 J2ME Developers' Guide Addendum" that the serial communications SHOULD work.
As I said - reading from the port (using the i85s Emulator) works - but writing to the port - freezes the execution. So this means that my connection is up and running - just the write is not working.
I would love to be able to load my midlet to my phone - since maybe on the phone it WILL miraculously work. But in this direction I am stuck with the fact that the JAL Lite does not load "network capable apps" - whereas I cannot get my hands on the Web JAL (which DOES load network capable apps) - since I have not succeeded to get thorugh the 100 steps that you must go through in order to use it... see for yourself at https://idenonline.motorola.com/ideveloper/program/program_jal.cfm).
Help...? -
Labview visa couldn't read and write in wireless port
Hi I have a problem using wireless serial port in Labview. I couldn't read the data from the serial port. the Max could find the port com10 and com 11 and also find the software NI-visa 5.2 has been successfully installed.
Could anyone helps me with that? thanks!
my computer is win7 64 bits and my labview is 2012 32bits and visa is visa 5.2. Therefore is it have some problem with operating system with labivew?
and here is my program:Hi
there is no error occur when i use visa function. I plan to use two wireless serial port to commuicate. One is on microcontroller one is on laptop. For the testing whether they could work. I use two wireless ports to plug into USB on the laptop. One port is to write the string another is to read the string. The instrument is called "Silicon Labs CP210x USB to UART Bridge" in the hardware manager.
This is my program running like this:
also I try the basic VISA read/write examples to test. But it is still not work and report error. This is example runing basic visa read/write:
By the way.Could you tell me what do you mean the " send similar commands via a VISA test panel (MAX)"?
thanks
Kun L -
Reading ascii codes from serial port and plotting them
Hello
I am trying to build a VI that reads data (ascii values) from the serial port.
I am trying to build a wireless phonocardiogram. I have a microphone that acquires heart sounds. these signals are amplified and sent to a A/D converter to digitize them. the digital signal are sent to a base unit. The digitals signals received at the base unit have to be sent to a computer (over a serial port to view them).
I would like build a VI to plot ascii data received over the serial port.
I would like to plot those values so that the plot just looks like a analog signal (the one I had before A/D conversion).
Can anyone provide me some help?
Thanks in advance.....
Solved!
Go to Solution.Hi chaitu209
What is your transmission speed, samplerate, and bandwidth needed in your project? The bandwidth of the serial port is somewhat limited. Let me give you an example
Say you are using 115200 Kbit per second as transmission speed, one start bit/stop bit and parity bit, and 8 bit data. This will give you 115200/11 bytes pr second as the maximum theoretical transfer rate/sample rate. But if you are using up to 16 bit AD your maximum samplerate will be 115200/(2x11). So my advise to you is to use a binary transfer protocol not ASCII based protocol. This is not a problem in Labview with serial transmission.
Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far) -
Connect Flash to Serial Port with Local Socket Connection
Hey all,
So, I am trying to connect a Flash movie to a serial port
and have it react to the input coming in. Of course, Flash does not
have this capability built in, so I need a workaround. I also
program in Director, and there are easier ways to deal with this
there, but since there hasn't been an update in years, and for
other technical reasons, I would like to use a pure Flash program.
I also need to take advantage of some of the new hardware
acceleration improvements and horizontal sync issues that come with
running the Flash player full screen. So, there are some tools out
there that will let me stream the input from the serial port to a
web address. I figure I could use the local address and assign a
port number, then use Flash to create a local socket connection. I
am having issues opening ports on my computer, and a few other
things, but in theory, I think it should work. I know that I won't
get all the answers here, but if anyone has done anything of the
sort, or might know of some similar projects, it would really help.
I am more of a Director/Flash programmer, and not so much one on
the system level. So, opening local sockets, etc, while I am sure I
can figure it out, is still a bit beyond me. Thanks all!
- BruceYou may want to look into flash remoting, which would allow
you to push content to the flash movie. You could then write a
proxy between the source of your stream and flash the remoting
server. -
Eurotherm 2704 connection via serial port with ModBus
Hello guys,
first some words about my problem:
I have to develop a software which allows reading and writing the
temperature (we have 3 Eurotherm 2704) (I think some of you know this problem yet ).
I wrote already the program and it works, but I used "iTools OPC
Server" for my program and it was the demo version (works only 30 minutes).
The group doesn't want to pay for the iTools, I should solve this problem without
iTools .
In this forum I found out, that I can use the ModBus for it:
http://forums.ni.com/ni/board/message?board.id=170&thread.id=468139&view=by_date_ascending&page=2
I know, there are some similar threads here, but I am new with LabView
and need some help.
I downloaded one example “my modbus serial query.vi “
http://forums.ni.com/ni/board/message?board.id=170&thread.id=135288&view=by_date_ascending&page=2
but it does not work (I am not really sure, what I have to change in the
file)
With OPC Server I found out:
COM5
Baud Rate 9600
Parity: None
Flow Control: None
Data Bits: 8(RTU) (I can choose RTU, but where can I change to 8 bit ?! )
And by other properties, I have no idea what I have to change there
For Example
Modbus Data Unit In (all read and write mode ? Which one do I need to read the temperature and to set the set temperature?)
Modbus Command ?!!!
No idea.
I have folowing adresses (comms address 0x00030001, canonical address: 1)
Which one do I need ?!
I think if I get the signal from one temperature controller, I can do it for
other, but my problem is now THIS one.
Can you help me whit it ?
Should I use a other example ?! Maybe do you know better one?
Thank you, very much.
AlexanderHello Putnam and Christian,
I think the problem because you can not understand my question is my English, sorry
I'll try it again:
@Christian:
Thank you for the links, but I think all threads in NI Forum with topic "Help, Eurotherm 2704 ?" were written by me
You understood my problem correctly.
We have 3 temperature controllers and I have to develop a LabView program, which allows reading the temperature from the controllers. It should be possible to write the set temperature from LabView to temperature controller as well.
The controllers are connected already (I think with RS485) and I can read/set the data from/to controllers (with “iTools OPC Server”), but I have to change my program so, that it works without “OPC Server”
@Putnam:
In the meantime I found out, why I got an error with “my modbus serial query.vi” (the solution was very simple, I had to close the OPC-Server ).
It runs now and I try to understand now how the VI exactly works.
Maybe you can help me with it?
I try to explain what I understood, if something is wrong, tell my please:
The “my modbus serial query.vi” allows to read the multiple values (maximum 125 register) (default block read size is 125) from controller (I can see the data in the register array). In each register I have values for different variables. The Modbus address of Loop1 PV (I need this value) is known ( 00001, Eurotherm manual).
Does it mean that the first element in the register-array is the value for the temperature from Loop 1 ?! (multiplicated by a factor, if it is correct, how can I find out this factor? It is linear?)
And if I need the value of Loop2 (the address is 01025), I have to set the start address for example to 1000 and in this case the 25-th element in register-array is the value for PV Loop 2 ?!
I got this idea, after I left the laboratory and could not try it out. I can do it first at Monday, but I would know if it is correct what I think.
If it is correct, I think I will able to change “my modbus serial query.vi” on my own, that it works in my program.
Or there is a better example/solution than “my modbus serial query.vi” ?!
The other problem would be writing of temperature, but I will ask about it later . First temperature READING problem!!
Thank you!
Alexander.
Message Edited by alexphysiker on 01-29-2010 05:30 PM -
Windows Kernel Debbuging: Debug over virtual serial port with WDK 8.1
I'm currently having some issues doing kernel debugging of a Windows 7 x64 target from my Windows 8.1 x64 host machine. I'm running Visual Studio 2013 with WDK 8.1 on my host and have provisioned my target machine running in VMWare.
Here are my configurations for the target machine. It was configured by reading mostly from here - http://www.codeproject.com/Tips/545835/Kernel-Mode-Debugging-in-a-VM-using-Visual-Studio :
Windows 7 x64
Serial port COM2 with VMWare with name \\.\pipe\com2. All proper options in VMWare are checked
Debug flag for OS enabled through msconfig. Debug port is COM2 running at 115200 baud.
I ran the test target client "WDK Test Target Setup x64-x64_en-us.exe" on the machine before provisioning the computer
I was able to provision the computer properly -- it created the WDK Remove User account. However, I'm running into some issues actually debugging. Below are the steps
Launch the Windows 7 x64 target image in VMWare and wait on the boot menu
In Visual Studio (host machine), go to Debug -> Attach to process -> Select my computer -> Select process "Kernel" -> Attach
In VMWare, press enter to boot Windows
It takes a while, but on my host machine, Visual Studio eventually connects. I can choose to "Break All" and actually use the debugger.
However, I can't seem to connect to the debugger if I don't do it before booting the kernel. And I can only attach once. For example, I can't let Windows initialize to the desktop and then build my driver and begin debugging. The debugger will always hang on
"Waiting to reconnect...". The same goes for if I begin debugging on kernel initialization, decide to stop debugging, then try to reconnect or reattach; it will hang on "Waiting to reconnect..." indefinitely as well.Follow the directions here: https://msdn.microsoft.com/en-us/library/windows/hardware/jj200334%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
You are using user mode debug setup menus, that won't work.
Mark Roddy Windows Driver and OS consultant www.hollistech.com -
Read and Write Files to user from Forms Server
We are developing an application that requires us to rread and write files to the user system. We are deploying using the developer/forms server and this is not happenning. The text_io package and the d2wkutil operate on the application server system, not the user system. So is there a method to read the file contents into the app and write files out to the user system across the web. Thanks.
developer6 can interact with javabeans. the javabean runs as an applet on the client machine. all you have to do is setup a javabean that read and write to your client machine.
when you test your application, work with java console open so you'll be able to debug your appliacion, if you'll receive java security execption you may need to sign this javabean. look at sun site for info regarding the usage of javakey for signing java classes and jars.
Maybe you are looking for
-
Do I not get full versions of the CC software when I buy a CC membership?
So I bought my CC membership back in January I think. And the first thing I did was install Premiere Pro CC. I needed it. Now about a month later, I need it again, and it says that I'm on a trial version. I signed into my CC, and tried again, but it
-
Error in running juit test case for struts2 action class
Hi, I am getting error when i am running my junit test case for struts2 action class. Here is the code. public class RoleMasterNewActionTest extends StrutsTestCase { public void setUp() throws Exception { super.setUp(); ObjectFac
-
Dear All, I changed something in a form after that I compile it,then I got the following error Oracle Forms Designer Oracle Forms Designer has encountered a problem and needs to close.we are sorry for the inconvenience. If you were in the middle of s
-
I'm working on a student project in 3rd year undergrad, we are setting up a mock security and control system for a nuclear reactor. We've had about two months (3hours a week) of using Labview for experience, and a semester of using Matlab in first y
-
Hi, We are using the CMS for our landscape ( XI 3.0) from some time, DEV to QA transports are moved with out any problem but i am facing the below problem when i move few transports from quality to production. In the Assembly tab i am selecting the p