[Gambas-user] using events of serial ports for reading how_?
T Lee Davidson
t.lee.davidson at gmail.com
Tue Aug 14 02:10:17 CEST 2018
Here, try this simple program, PICCORO:
[code]
' Gambas module file
Public SComm As SerialPort
Public databuffer As String = ""
Public DataHasBeenRead As Boolean = False
Public Sub Main()
SComm = New SerialPort As "SComm"
SComm.PortName = "/dev/ttyS1"
SComm.Speed = 9600
SComm.Parity = 0
SComm.DataBits = 8
SComm.StopBits = 1
SComm.FlowControl = 2
Try SComm.Open()
If Error Then
Print "Error: " & Error.Text
Quit
Endif
Print #SComm, Chr(2) & "_" & Chr(3)
Do
Wait 0.1
Loop Until DataHasBeenRead
Print databuffer
End
Public Sub SComm_Read()
Read #SComm, databuffer, Lof(SComm)
DataHasBeenRead = True
End
[/code]
Does it work? If so, then problem solved.
I'm done. Good luck.
___
Lee
P.S. Tony was certainly not "srcreaming garbage" [sic], just pointing out facts of your behavior.
The world may not be the "little hole of mysql", but Gambas works with the major non-proprietary and open-source databases MySQL
and PostgreSQL. If you need it to work with proprietary databases, you are invited to develop and contribute the code to do so.
Or, perhaps Lazarus would meet your expectations. However, I doubt the dedicated and helpful people at the Lazarus forum would
tolerate your unappreciative and obnoxious attitude for very long.
On 08/13/2018 03:28 PM, PICCORO McKAY Lenz wrote:
> Tony all the information was given:
>
> 1 it's a fiscal printer, there's no sense in give you that are a epson dot matrix due you need the kit's in place to test
>
> 2 i tested and make many mothns ago a POS systems so test with command line the kit was done! please!
>
> 3) of course commands are ver very correct! i receive data but not as planned by the event as T Lee said!
>
> about the odbc, i provide the odbc driver info, TDS do you noted and read the issues?
> and connection string info, i not the only that suffers the odbc problem, the world are not the "little hole of mysql" right!
>
> please seems are you the guy that are "srcreaming garbage"
>
> Lenz McKAY Gerardo (PICCORO)
> http://qgqlochekone.blogspot.com
>
> 2018-08-13 15:22 GMT-04:00 Tony Morehen <tmorehen at ajm-software.com <mailto:tmorehen at ajm-software.com>>:
>
> I give up trying to help you. I asked 3 questions. You ignored two and said there is no point in answering the other. How
> can anyone help you when you refuse to provide any information?
>
> It's like the ODBC problems you've been yelling and screaming about. You don't even give basic information like what odbc
> driver you are using, including version.
>
>
> On 2018-08-13 02:48 PM, PICCORO McKAY Lenz wrote:
>> well it's a fiscal printer, so there's no sense in tell you taht it's a epson dot matrix
>>
>> i put more delay and now event raised! i mean, 0.5 ms in main module event in the property event!
>> and 0.1 ms in the read function..
>>
>> but if i put tyhe delay in any other place that are not in the main there's no read event raised!
>>
>> ans somethings does not happened (very rare times)
>>
>> Lenz McKAY Gerardo (PICCORO)
>> http://qgqlochekone.blogspot.com <http://qgqlochekone.blogspot.com>
>>
>> 2018-08-13 13:52 GMT-04:00 Tony Morehen <tmorehen at ajm-software.com <mailto:tmorehen at ajm-software.com>>:
>>
>> Perhaps you could upload the latest version of your code?
>>
>> What printer are you testing this against?
>>
>> Have you tried connecting via a terminal program to your printer? This will double check your connection settings and
>> let you see the actual response to the commands you are sending. Another test is to use a serial port monitor or
>> sniffer to view your program's serial port activity.
>>
>>
>> On 2018-08-13 11:35 AM, PICCORO McKAY Lenz wrote:
>>>
>>> 2018-08-13 11:16 GMT-04:00 T Lee Davidson <t.lee.davidson at gmail.com <mailto:t.lee.davidson at gmail.com>>:
>>>
>>> You create the printer object, open its port, write to the printer requesting a status report, and then
>>> *immediately* you
>>>
>>> manually read the response. After that, for some odd reason, you read the "dataread" property twice, and then the
>>> program ends.
>>>
>>> ok but remove later those calls and does not triggered the read event!, inclusivelly if i put a loop in the main
>>> module that waiuth "something"
>>>
>>> If you don't call the "rp" function, the program drops through the two "dataread" property reads and ends. When
>>> did you expect
>>> the _Read event would have a chance to be raised?
>>>
>>> was just a experiment, i removed in furter test as i said
>>>
>>>
>>> Not sure exactly what you mean with that statement, but it may be the very idea I am trying to impress upon you.
>>> Your manual
>>> read subroutine gives the printer 500 milliseconds to respond. Why don't you give the Main module at least 500
>>> milliseconds to
>>> allow the printer to respond and raise the _Read event?
>>>
>>> i put a loop into as i said in the previous paragraph, but still does not happened!
>>>
>>>
>>>
>>> Or, why not use a semaphore that is visible to the Main module and loop until the _Read event has had an
>>> opportunity to fill the
>>> "databuffer"?
>>>
>>> oh, of course was working in this way, was my first code, ok great but i wish to deal with the read event ..
>>>
>>>
>>> You may not have specified that the SerialPort stream should be watched, but it would be logical that Gambas
>>> automatically
>>> WATCHes a SerialPort in order to be be able to raise the _Read event. (http://gambaswiki.org/wiki/lang/open
>>> <http://gambaswiki.org/wiki/lang/open>)
>>>
>>> yeah yeah, when i said "hang at end" i mean that with gambas 3.8 when last sentence executed the programs ends
>>> normally, with 3.11 the programs "seems end" but the "play" button of the ide still are deactivate and the ide
>>> indicates program does not end...
>>>
>>>
>>>
>>> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>>
>>
>>
>> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>>
>>
>
>
>
>
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
More information about the User
mailing list