English
Entrance

COM Port of Arduino reading

 

Member
4968348
Hello together,

be new here in the Forum and I time 'ne question to that o.g. Topic
I try over the virt. Port my of Arduino sent
Zeichenkette To reading.
with the "hauseigenen" seriellen Monitor the IDE and another
Termialprogramm (RS232 terminal) works the wonderful.
unfortunately power the XProfan Prog something Problems.
with the 1. Durchlauf becomes The empfangende Zeichenkette not displayed.
with whom subesquent Durchläufen becomes each The empf. Zeichenkette of previous (!) Durchlauf correctly displayed etc.

what runs there wrong ?

here time the View source: ( XProfan11 , partly from the Help-File entnommen)

'============================================================================
' COM receptions
'============================================================================

Declare a$, f%, end% , Sendestring$ , Empfangstring$ , Durchlauf%

Proc GetComInput
Parameters id%
Declare x$ , Empf$
x$ = @ReadCom$(id%, 1)
@ComError(id%)
Print x$;

WhileNot x$ = ""
x$=@ReadCom$(id%,1)
@ComError(id%)
print x$;
EndWhile

ENDPROC

Window 0, 0 - 600, 600

f% = @OpenCom("COM5", 100, 100)

end% = 0
Durchlauf% = 1

GetComInput f%
WhileNot end%

a$ = @Input$("Zeichen 's' for senden", "", "s")

If a$ = "" ' end with discontinue
end%=1

ElseIf a$ = "s" ' characters Send
print @stature$("Duchlauf 00 : ",Durchlauf%);
print @stature$("Wert gesendet 00 : ",Durchlauf%);
Sendestring$ = @stature$("00000",Durchlauf%)

@WriteCom(f%,Sendestring$)

sleep 100
print "empfangen = ";
GetComInput f% ' conceived characters reading

INC Durchlauf%
a$ = ""
print
Endif
EndWhile

@CloseCom(f%)
End

Nachtrag:
Arduino UNO by me on the COM 5 (USB) connected
the behaviour shows itself in the BS Win XP
in the BS Win11 funkt it not at all with the Profan-Prog.

with the hauseigenen ser. Monitor the Arduino IDE very well
The Arduino sketch must means functions
 
05/28/25  
 




E.T.
Kanns not testing, but time drüber geschaut:

The first appeal of "GetComInput" results without the "@WriteCom(f%,Sendestring$)"  to the Hauptschleife.

first in the 2. appeal in the Hauptschleife is the "@WriteCom(f%..."  thereby, there's f% though yet 1 of 1. Durchlauf, because first later in the Loop increased becomes.

so probiert:
...
' GetComInput f%
WhileNot end%
...

there begins The "Anzeige" with Durchlauf 1

(tested without Fehlermeldungen under Win10, though too no "Gerät" connected)
 
Grüße aus Sachsen... Mario
WinXP, Win7 (64 Bit),Win8(.1),Win10, Win 11, Profan 6 - X4, XPSE, und 'nen schwarzes, blinkendes Dingens, wo ich das alles reinschütte...
06/01/25  
 




Member
4968348
Hello Mario,

[

E.T. (01.06.2025)
Kanns not testing, but time drüber geschaut:

The first appeal of "GetComInput" results without the "@WriteCom(f%,Sendestring$)"  to the Hauptschleife.

so probiert:
...
' GetComInput f%
WhileNot end%
...


... has none success brought

E.T. (01.06.2025)
first in the 2. appeal in the Hauptschleife is the "@WriteCom(f%..."  thereby, there's f% though yet 1 of 1. Durchlauf, because first later in the Loop increased becomes.


'f%' is the Return Value of @openCom, So the Port-lever ! and becomes in the Loop neither increased

I have the trouble mitlerweile except for some blemish resolved, see View source below.
You written: you have no "Gerät" to that testing. You benötigst not absolutely one Arduino board with suitable Prog, around the whole To testing.
If you one " USB to Serial Adapter with CH340" have ....such a thing...)



simply on the Adapter Pin TxD with Pin RxD contact and over the Gerätemanager whom Port find out. unfortunately functions only Port 1 - 9, Why ??? Getestet with Win10

I use the Prog moreover, circa over one Arduino a Schrittmotor To steer. I send one 'Befehl' and the board sends then whom status back .

here the revised View source:

23 kB
Hochgeladen:06/02/25
Downloadcounter0
Download
 
06/02/25  
 




Member
4968348
... achso,

so is the View source rather readable
'====================
' COM receptions
'====================
Declare input$, Port$ , Port_Hnd%, end% , Sendestring$ , Empfangstring$

Proc GetComString

    Parameters id%
    Declare characters$ , Empf$

    While 1

        characters$ = @ReadCom$(id%, 1)
        sleep 100'necessary, Why ???
        @ComError(id%)
        casenot characters$ = "" : break'Loop first leave, if characters anliegt

    endwhile

    @Set("Decimals",0)

    Whilenot characters$ = ""'Loop as long as characters present are

        Empf$ = Empf$ + characters$
        characters$=@ReadCom$(id%,1)'characters reading
        @ComError(id%)

    EndWhile

    return Empf$

ENDPROC

Window 0, 0 - 800, 600
Def $Port "COM5"'on / of these Port becomes gesendet / receive
Def $Port_Parameter ":9600,n,8,1"'Port Settings
print "    characters Send and receive on Port: " + $Port + ":\n"
Port_Hnd% = @OpenCom($Port, 100, 100)

ifnot Port_Hnd% = -1' Port is available

    @setCom(Port_Hnd%, $Port + $Port_Parameter)
    end% = 0

    WhileNot end%

        input$ = @Input$("beliebige (Alpha)Zeichenkette eingeben", "", "beliebige Zeichen")

        If input$ = ""' end with <Abbruch>

            end%=1

        else

            Sendestring$ = input$
            @WriteCom(Port_Hnd%,Sendestring$)'Zeichenkette Send
            print " gesendet watts : "; Sendestring$
            Empfangstring$ = GetComString(Port_Hnd%)'conceived Zeichenkette
            print "empfangen watts : "; Empfangstring$
            clear Empfangstring$
            print

        Endif

    EndWhile

else

    print "Port " + $Port + " not verfügbar"
    waitinput

endif

@CloseCom(Port_Hnd%)
End
 
06/02/25  
 



Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

147 Views

Untitledvor 0 min.
Uwe ''Pascal'' Niemeier vor 7 Tagen
Walter06/15/25
ByteAttack06/12/25
Member 496834806/11/25
More...

Themeninformationen

this Topic has 2 subscriber:

Member 4968348 (3x)
E.T. (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie