Serial Lib von Ginny

Deutschsprachiges X#-Forum – German language forum

Moderator: wriedmann

lagraf
Posts: 417
Joined: Thu Jan 18, 2018 9:03 am

Serial Lib von Ginny

Post by lagraf »

Ich verwende in meinen Kassenprogrammen die SerialLib von Ginny zur Ansprache von seriellen Kundendisplays. Ich erhalte beim compilieren den Fehler

Code: Select all

error XS9002: Parser: unexpected input 'Callback'
weil er die Callback Funktion CommWatchProc nicht mag.
Gibt es da bereits eine Umsetzung für X#?
LG Franz
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Serial Lib von Ginny

Post by wriedmann »

Hallo Franz,
das ist ein Fehler im XPorter - er entfernt das Attribut "callback" bei der Funktions-Definition nicht.
An und für sich wäre es sinnvoll, diese Klasse für .NET komplett neu zu schreiben.
Für eine Umsetzung nach X# sehe ich aber auch so keine größeren Probleme.
Vielleicht sollte sich das jemand anschauen.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
TimothyS
Posts: 58
Joined: Thu Dec 15, 2016 3:39 pm
Location: Australia

Serial Lib von Ginny

Post by TimothyS »

Hi Franz,

Excuse the English. I had the exact same problem when I was porting my VO app to Vulcan. Ended up using the DotNet serial class. Easy to do and works well.

Regards,
Tim
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Serial Lib von Ginny

Post by Chris »

Guys,

I agree with Tim, better just use the .Net classes instead. But good point about VOXporter needing to take care of this, can you please one of you guys send me that library for test purposes (I had never used it myself in VO)?
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
lagraf
Posts: 417
Joined: Thu Jan 18, 2018 9:03 am

Serial Lib von Ginny

Post by lagraf »

Hi Chris
This is the Lib I use with VO 2.x!
Franz
Attachments
_SerialLib20.zip
(8.44 KiB) Downloaded 26 times
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Serial Lib von Ginny

Post by Chris »

Thank you! So I see the problem does not have to do with the CALLBACK keyword, but it's that VOXporter tries to declare the delegate in the middle of a multi line expression, will take care of this.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
lagraf
Posts: 417
Joined: Thu Jan 18, 2018 9:03 am

Serial Lib von Ginny

Post by lagraf »

Hallo Wolfgang,
bist du da sicher? Im Code knallt der XPorter die Static Local Definition genau zwischen die Parameter des Aufrufs hinein, die gehört doch darüber?

Code: Select all

BEGIN SEQUENCE
// Create 2nd thread to watch for comm event
ptrCommWatchThread := CreateThread(	; // Use VO Wrapper to CreateThread()
	NULL,				; // pointer to security attributes
	0,				; // initial thread stack size
#warning Callback FUNCTION modified TO use a DELEGATE by xPorter. Please review.
// 		@CommWatchProc(), 	; // pointer to thread function
STATIC LOCAL oCommWatchProcDelegate := CommWatchProc AS CommWatchProc_Delegate
	System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(oCommWatchProcDelegate), ; // pointer to thread function
	struCommData, 			; // argument for new thread - no '@'
					; // because AS STRUCTURE IS pointer already
	0, 				; // creation flags for thread
	@dwWorkerThreadID)		  // pointer to returned thread ID
...
END SEQUENCE
LG Franz
Ooops, Chris was 6 mins faster!
lagraf
Posts: 417
Joined: Thu Jan 18, 2018 9:03 am

Serial Lib von Ginny

Post by lagraf »

Was mir auch noch auffällt sind 2 warnings, die eigentlich unsinnig sind:

Code: Select all

warning XS0170: Use of possibly unassigned field 'hEvent'
Der Code gekürzt

Code: Select all

METHOD Read( nMaxLength )
...
	BEGIN SEQUENCE
		struOverlapped.hEvent := CreateEvent(NULL, TRUE, FALSE, NULL)
		IF struOverlapped.hEvent == NULL // Hier keine warning
...
	END SEQUENCE
	IF struOverlapped.hEvent != NULL // Hier die warning!!!
...
Warum wird hEvent 1x angemeckert und ein anders Mal nicht?
Bei der Methode Write das gleiche!
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Serial Lib von Ginny

Post by wriedmann »

Hallo Franz,

das hat damit zu tun, dass die Variable hEvent innerhalb einer Begin-End Sequence besetzt wird, und nach dieser abgefragt wird.
Wenn es in CreateEvent() zu einem Fehler kommt, wird die Variable hEvent effektiv nicht besetzt.
Um diese Warning wegzubekommen, solltest Du vor dem begin sequence den Wert Null zuweisen.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
lagraf
Posts: 417
Joined: Thu Jan 18, 2018 9:03 am

Serial Lib von Ginny

Post by lagraf »

Alles klar,
aber weiß der Compiler nicht, dass das Programm auf jeden Fall 1x beim CreateEvent vorbeikommt? Außerhalb von BEGIN SEQUENCE und END SEQUENCE wird es doch nie vorbeilaufen?
Franz
Post Reply