LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-26-2011, 02:44 PM   #1
mafesabu
LQ Newbie
 
Registered: Jan 2011
Posts: 6

Rep: Reputation: 0
More than one Question and Ask,Serial PORT


Hello!!

I'm sending a question by serial port and receiving the answer, so my problem is that i need to do more than one question and off course receive more than one reply!

is this possible? To do more than one question at the same time? and receive the answer too???

How can i do it???

please help mee!! i'll be attentive to your reply!
 
Old 01-26-2011, 05:35 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Are you writing software to do this, or using some other existing tools? If the latter, what are they? If the former, please provide more detail about your application, especially things like programming language. Show code fragments to demonstrate what you have already tried. Code fragments should be posted on [CODE ] tags to preserve formatting.

In general, querying a device through a serial interface requires that the reply is received before a subsequent query is sent. Your tool or software must be able to handle this. If there are multiple tools running concurrently, then they must all use some convention to prevent concurrent access to the serial port. One common mechanism for this is the use of lock files. These behave like a mutex: if the lock file exists, wait until it is removed, and then create your own lock file, removing it when done, to allow other software to access the resource. To work correctly, all tools sharing the resource must agree on this use of a single lock file.

If you are programming the protocol used to manage the conversation between the host and the serial device, it is possible to tag replies with identifiers that the receiver uses to match replies with queries. This allows multiple outstanding queries to exist between the host and the device, and replies subsequently received can be correctly matched with the respective queries.

--- rod.
 
Old 01-27-2011, 11:47 AM   #3
mafesabu
LQ Newbie
 
Registered: Jan 2011
Posts: 6

Original Poster
Rep: Reputation: 0
My app is being developed in Gambas2 and is conected to a converter ZAPI AC-4 96V.
so, i can do comunication between them with one question and one reply.. buti need more than one as i told you...
 
Old 01-27-2011, 02:33 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I'm sorry, but I don't understand what obstacle you are trying to overcome. It sounds like you are able to send a single query, and receive the accordant response. What is stopping you from performing this process iteratively?
--- rod.
 
Old 02-09-2011, 10:44 AM   #5
mafesabu
LQ Newbie
 
Registered: Jan 2011
Posts: 6

Original Poster
Rep: Reputation: 0
The thing is th next... imagine that i need to communicate my pc with converter for to ask about 3 thing: velocity, charge of batteries and temperature.

Now I'm reading velocity iteratively but i need to send one more question for the charge and one more for the temperature, is this possible to do in gambas???? and while my pc is asking and receiving keep running the rest of the code??? I need a thread ? it's possible in gambas?
 
Old 02-09-2011, 11:34 AM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Well, perhaps my lack of understaing of gambas is the problem. I assume it is/has some kind of procedural programming language that includes looping. Can you show us the code that you use to iteratively query and read the one parameter that you are presently reading?

As I see it, your code should look something similar to this pseudo-code:
Code:
while forever
   sendQuery( "velocity?" )
   velocity = readReply()

   sendQuery( "battery?" )
   battery = readReply()

   sendQuery( "temperature?" )
   temperature = readReply()
What am I missing?

--- rod.
 
Old 02-09-2011, 02:14 PM   #7
mafesabu
LQ Newbie
 
Registered: Jan 2011
Posts: 6

Original Poster
Rep: Reputation: 0
You are missiing to keep runing the rest of the code while this "While" is executing.... this is my email.. send me yours please..
mafer_lapia@hotmail.com
 
Old 02-09-2011, 02:57 PM   #8
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
There is nothing I could/would contribute by e-mail that I would not post here. Taking conversations off-line is contrary to the purpose of forums such as these.
Since your code seems to be doing some kind of monitoring function, I will speculate that one of it's principle constructs is a main loop, which performs other work in addition to the monitoring aspect. With respect to the posted psuedo-code, can you not simply add your 'rest of the code' to the main loop?

No matter what the overall construct of the program, what is stopping you from using the sequence of query-read pairs; one for each parameter you need to read? If your code reaches a point where it does one query, it should be able to simply do two more.

Is there something fundamentally different about gambas that makes this difficult or impossible? What programming construct is required to invoke the existing query?

--- rod.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is a USBtty (USB serial port) treated the same as tty (normal serial port) in C? spudgunner Programming 1 11-12-2010 02:19 PM
Linux Serial Port question blackzone Linux - Networking 1 08-15-2004 10:49 PM
Serial Port Programming Question Darktyco Programming 8 03-23-2004 06:13 PM
Treo 90/Serial Port Question gizmogadgetus Linux - Laptop and Netbook 1 11-02-2003 06:29 PM
Serial Port Question... gizmogadgetus Linux - Newbie 1 10-30-2003 05:09 AM


All times are GMT -5. The time now is 06:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration