Lazarus

Programming => General => Topic started by: Aruna on September 23, 2024, 03:51:29 am

Title: Error: Wrong number of parameters specified for call to "Assign"
Post by: Aruna on September 23, 2024, 03:51:29 am
I am trying to get serial communication working from the IDE to a Arduino Nano. I am getting this error:

Code: Pascal  [Select][+][-]
  1. unit1.pas(46,30) Error: Wrong number of parameters specified for call to "Assign"

The code is below:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.btnTurnOnLedClick(Sender: TObject);
  2. var
  3.   f: TextFile;
  4.   data: string;
  5. begin
  6.  // Correct way to associate a file with the serial port ??
  7.  // Step 1: Associate the file variable with the serial device
  8.  
  9.     Assign(f, '/dev/ttyUSB0');  // Or 'COM3' on Windows
  10.     Rewrite(f);                 // Step 2: Open the device for writing
  11.     WriteLn(f, 'on');           // Step 3: Write data to the serial port
  12.     CloseFile(f);               // Step 4: Close the device
  13.  
  14.     WriteLn('Data sent to /dev/ttyUSB0');
  15. end;                                      

I have searched the documentation and Googled with no success. What am I doing wrong? Attached screenshot shows the error message. I do not wish to use synaser at this moment in time (maybe later but not right now) I want to get writing directly to the serial port working on the nano.
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Wallaby on September 23, 2024, 04:35:51 am
Use AssignFile, otherwise it thinks you're calling the Assign method of the form.
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Aruna on September 23, 2024, 05:02:59 am
Use AssignFile, otherwise it thinks you're calling the Assign method of the form.
Thank you @Wallaby, your fix works. I see the RX led flicker on the nano but the led on pin 13 does not stay on. It flickers though. When I test my code in the Arduino sketch using the serial monitor everything works as expected. Any ideas?
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Thaddy on September 23, 2024, 07:31:13 am
Assignfile is a fallacy. Use system.assign instead, so prefix assign with the unit. It does not matter too much in this case, but it is a non-solution that proves hard to get rid of. It is just there to prevent scoping issues, which are better solved by providing the scope - unit name - you mean explicitly. That is much cleaner.

All that AssignFile does is calling system.Assign anyway, which makes it imho code rot.
It is also not available in all modes, because it is defined in the objpas unit, as opposed to system.assign which is available in all modes.
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: rvk on September 23, 2024, 09:03:46 am
All that AssignFile does is calling system.Assign anyway, which makes it imho code rot.
They could have better made the AssignFile an inline function then  ;)
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: MarkMLl on September 23, 2024, 09:38:53 am
Use AssignFile, otherwise it thinks you're calling the Assign method of the form.
Thank you @Wallaby, your fix works. I see the RX led flicker on the nano but the led on pin 13 does not stay on. It flickers though. When I test my code in the Arduino sketch using the serial monitor everything works as expected. Any ideas?

You're inflicting several problems upon us here.

First, this partly duplicates your earlier thread at https://forum.lazarus.freepascal.org/index.php/topic,68606.msg530579.html which you abandoned.

Second, you've not given the community a testable project for this one. Now as it is Wallaby et al. have given you the correct answer, but I think it will be useful for you to consider the actual cause.

If you'd posted a proper project, it would be apparent that in the file causing the error you had imported other units which (we can reliably speculate) bring in implementations of Assign() other than System.Assign(), and that these are for some reason "closer" to the point of failure in a way that prevents polymorphism from telling the compiler which one to use.

And what is actually preventing the usual polymorphism from working? This:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.btnTurnOnLedClick(Sender: TObject);
  2. ...
  3.     Assign(f, '/dev/ttyUSB0');  // Or 'COM3' on Windows
  4.  

You're calling Assign() in the context of a class TForm1. That descends from TForm... and up at the top of the unit is would be apparent that you've imported Forms.

The compiler could, possibly, have made sense of that. But it hasn't (and frankly I don't blame it), because TForm.Assign() is hiding all other declarations of Assign().

And /that/ is why you have to use either AssignFile() or System.Assign().

MarkMLl
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: MarkMLl on September 23, 2024, 09:39:48 am
They could have better made the AssignFile an inline function then  ;)

Look on the bright side: most of the time that would have resulted in a compiler warning that inlines were being ignored.

MarkMLl
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Thaddy on September 23, 2024, 09:53:05 am
All that AssignFile does is calling system.Assign anyway, which makes it imho code rot.
They could have better made the AssignFile an inline function then  ;)
Yes. full code from objpas is this:
Code: Pascal  [Select][+][-]
  1. Procedure AssignFile(out f:TypedFile;p:PAnsiChar);
  2. begin
  3.   System.Assign (F,p);
  4. end;
and a couple of overloads with the same body but different string types...(code rot)
But it is neigh impossible to let people forget that there is such an atrocity as AssignFile.
I would have less trouble with it if it was a simple alias in system, not objpas.
That would also solve any ambiguities. it is also nitpicking from my side... :-X
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: MarkMLl on September 23, 2024, 10:09:32 am
I would have less trouble with it if it was a simple alias in system, not objpas.
That would also solve any ambiguities. it is also nitpicking from my side... :-X

Is the ability to use a dot i.e. System.something dependent on the mode of the compiler, or has there ever been a time when it was? I'm very much used to the module.entrypoint notation from Modula-2, but I don't know how long Pascal's supported it and there are no doubt some who conflate it with much newer namespace facilities.

MarkMLl

p.s /nits/ please Thaddy. English for lice, i.e. bugs.
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: marcov on September 23, 2024, 11:06:13 am
Is the ability to use a dot i.e. System.something dependent on the mode of the compiler, or has there ever been a time when it was? I'm very much used to the module.entrypoint notation from Modula-2, but I don't know how long Pascal's supported it and there are no doubt some who conflate it with much newer namespace facilities.

Afaik TP already had it.


Quote
p.s /nits/ please Thaddy. English for lice, i.e. bugs.

Nits are afaik the lice's eggs, not the (mature) lice themselves. But they are often confused, also in Dutch (neten/Luizen)
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Aruna on September 23, 2024, 12:04:30 pm
Assignfile is a fallacy. Use system.assign instead, so prefix assign with the unit. It does not matter too much in this case, but it is a non-solution that proves hard to get rid of. It is just there to prevent scoping issues, which are better solved by providing the scope - unit name - you mean explicitly. That is much cleaner.

All that AssignFile does is calling system.Assign anyway, which makes it imho code rot.
It is also not available in all modes, because it is defined in the objpas unit, as opposed to system.assign which is available in all modes.
Thanks @Thaddy I will use system.assign ( I did not know until you mentioned it ) do you have any thoughts on why I am unable to get the nano led to light up?
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Aruna on September 23, 2024, 12:27:51 pm
you've not given the community a testable project for this one
Even after compressing my zip is over the 500kb limit of the forum. Here is the source for anyone interested. (https://drive.google.com/file/d/1YzT0yJ_g_MSvHWf3XqfbfHpuKEWmuTfw/view?usp=sharing)

If you'd posted a proper project, it would be apparent that in the file causing the error you had imported other units which (we can reliably speculate) bring in implementations of Assign() other than System.Assign(), and that these are for some reason "closer" to the point of failure in a way that prevents polymorphism from telling the compiler which one to use.
Single unit no other imports :-)
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: MarkMLl on September 23, 2024, 01:13:35 pm
you've not given the community a testable project for this one
Even after compressing my zip is over the 500kb limit of the forum. Here is the source for anyone interested. (https://drive.google.com/file/d/1YzT0yJ_g_MSvHWf3XqfbfHpuKEWmuTfw/view?usp=sharing)

If you'd posted a proper project, it would be apparent that in the file causing the error you had imported other units which (we can reliably speculate) bring in implementations of Assign() other than System.Assign(), and that these are for some reason "closer" to the point of failure in a way that prevents polymorphism from telling the compiler which one to use.
Single unit no other imports :-)

OK, but at that point I have to ask: why are you trying to use ordinary file operations with a serial port? Did you read (mark, learn and inwardly digest) the examples I gave you in the other thread?

MarkMLl
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Bart on September 23, 2024, 01:27:18 pm
Can you please move the discussion about LED's to another thread.
This thread is supposed to be about Assign().

Bart
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Aruna on September 23, 2024, 01:30:02 pm
OK, but at that point I have to ask: why are you trying to use ordinary file operations with a serial port?
Everything is a *file* in linux, is why :-)
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Aruna on September 23, 2024, 01:38:42 pm
Can you please move the discussion about LED's to another thread.
This thread is supposed to be about Assign().Bart
If you look at my initial post again you will see it says:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.btn[b]TurnOnLed[/b]Click(Sender: TObject);
The led is related and part of my problem. I can move things to another thread but then I think it is only fair and reasonable we also open new threads about polymorhism, nits, lice, dot systems? It is sad and disappointing when people with your kind of experience and expertise fail to see the obvious and proceed to assume and speculate where I work on evidence based facts. NO offence meant to anyone and hopefully what I said will be taken in the spirit it was meant in. It would be much more helpful if you are unable to contribute meaningfully, not to do so at all?
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: MarkMLl on September 23, 2024, 01:44:26 pm
OK, but at that point I have to ask: why are you trying to use ordinary file operations with a serial port?
Everything is a *file* in linux, is why :-)

Everything IS NOT a file in unix.

Most things appear in the filesystem namespace: except network interfaces, open sockets, internal firewall rules endpoints, arbitrary USB devices... I could go /way/ on.

What's more, something like /dev/ttyUSB0 might be a file in unix, but that doesn't mean you can manipulate it like a file from Pascal: you can't. And that's (a) why things like serial.pp, SynAser and so on exist, and (b) why serial libraries/components (and network protocol ditto etc.) aren't applicable to ordinary files.

If you don't believe me, then follow through what your code is doing all the way to the kernel syscalls, and find out where it's not behaving like you expected.

MarkMLl
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Aruna on September 23, 2024, 02:08:26 pm
Everything IS NOT a file in unix.
I said linux not unix :-) and your veering off-topic ( ...again)

What's more, something like /dev/ttyUSB0 might be a file in unix, but that doesn't mean you can manipulate it like a file from Pascal: you can't. And that's (a) why things like serial.pp, SynAser and so on exist, and (b) why serial libraries/components (and network protocol ditto etc.) aren't applicable to ordinary files.
You may want to reconsider that after watching this (https://www.google.com/search?sca_esv=445c9ec50e6b4223&sca_upv=1&sxsrf=ADLYWIIYWGUSwNLjQ4IBXxRFqKR01qcp4A:1727093150707&q=pascal+arduino&tbm=vid&source=lnms&fbs=AEQNm0CRraR4AFMOJtZDUPiZk_hDDcI2gsUCGe9dZxqjUB5Fjbg9g5Dvlwra67P-0Tq9xG3V6wtiiRWn3AMd3MwHGOtFdRgA2KD1bARv7g8btBn6Jlpu6imrEpstW2EY-NoR5DuL98FVdmK9OH0IsUWSs3kBQGNjkiv0KxcLJR6RW4EGB5adX2SRbewUlFeAZEE3zLI2szaVLCj1-4TxmjOoB-MtUkPttA&sa=X&ved=2ahUKEwjmvPetg9mIAxWXFzQIHS7rHqIQ0pQJegQIEBAB&biw=1680&bih=863&dpr=1#fpstate=ive&vld=cid:a6037fa6,vid:UfQIkNl7gKM,st:0)
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: MarkMLl on September 23, 2024, 02:31:44 pm
You may want to reconsider that

I've got much more important things to do with my time.

MarkMLl
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Thaddy on September 23, 2024, 02:32:06 pm
Marcov is right, the assignfile/closefile procedures first appear in the OO versions of TurboPascal. (5.5, 6 and 7)
But that does not mean it is standard pascal and both are dependent on either {$mode objfpc} or one of the Delphi modes, actually any mode that draws in the objpas unit.
I have updated the wiki to reflect that: Assign and Close are independent from the mode. AssignFile and CloseFile are dependent on mode. That alone may be enough to never use them again: they are not portable, although many seem to think they are.
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Aruna on September 23, 2024, 02:40:46 pm
You may want to reconsider that
I've got much more important things to do with my time.
Denial can be harmful because it prevents individuals from addressing reality and dealing with problems in a constructive manner. By refusing to acknowledge harmful behaviors or negative situations, denial perpetuates cycles of harm. This could involve repeating destructive habits, remaining in toxic environments, or enabling others' unhealthy behavior.

In essence, denial might offer temporary emotional relief, but it often comes at the cost of long-term well-being. Recognising and confronting reality, though difficult, is a crucial step toward growth and problem-solving. Just so you know that link I sent is a kid doing exactly what you said is not doable using pascal. Sadly when I tried to replicate his code I hit brick walls which am yet trying to get around.

The reason I asked you to watch is because I firmly believe 'your' very much more experienced and technically savvy than me so might see what am not seeing? And my turn to tell myself stop deviating from the subject at hand :-)
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Thaddy on September 23, 2024, 02:42:26 pm
Read my remark about portability: using the convenience functions is not portable.
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: MarkMLl on September 23, 2024, 03:27:58 pm
The reason I asked you to watch is because I firmly believe 'your' very much more experienced and technically savvy than me so might see what am not seeing? And my turn to tell myself stop deviating from the subject at hand :-)

Flattery. Look, I /really/ have more important stuff to do and I'm sure you can understand the fact that I'm somewhat pissed off that you're ignoring the points I've made. Now this might sound like a fallacious "appeal to authority" but the fact is that I've got 40 years experience writing comms software and that by and large my stuff works.

Now you've just sent me a Google link (which required that the browser I pasted it into is now polluted by an acceptance of Google USA's T&Cs) but /which/ video am I supposed to be looking at: the 9:40 one?

To emphasise my point from another thread: if you write to /sys/.../backlight you aren't talking to a device directly, but to a kernel module which believe it can support that device and has created the backlight endpoint in the /sys tree of pseudofiles. Same applies to stuff in /proc... the device itself might not actually be expecting to transfer any data via a normal handle, but if the driver thinks there is state which can be usefully controlled then it might create something that /looks/ like a file.

Nearer home, if you look at my example code you'll see that there's some which goes out of its way to identify a (serial) device type: e.g. FTDI, WCH and so on (typically, so that it can find the instrument in which the chip is embedded). But that's not info that the device itself is exposing, rather it's the driver: /and/ there's a pseudofile which identifes the kernel module implementing the driver.

Now, what video did you want me to watch, or (even better) can you tell me the problems you're having interpreting things? Because right now I think that you're stuff because you're not making a distinction between "file" as defined by Pascal, and "file" as defined by the kernel... which in the case of unix (and I say unix advisedly, since I'm including SunOS etc.) has additional calls to set Baud rate, DTR state and so on which you're blithely ignoring.

MarkMLl
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Aruna on September 23, 2024, 04:02:23 pm
/which/ video am I supposed to be looking at: the 9:40 one?
Yes please. Pay attention at 3:40 then again at 7:50 please and thank you. His code works as we can see in that video but when I try and type in the exact same code it chokes on me?

To emphasise my point from another thread: if you write to /sys/.../backlight you aren't talking to a device directly, ...
Oh dear sorry I totally forgot. My lap-toppie under /sys/class/backlight has acpi_video0 and intel_backlight

Nearer home, if you look at my example code you'll see that there's some which goes out of its way to identify a (serial) device type: e.g. FTDI, WCH and so on (typically, so that it can find the instrument in which the chip is embedded). But that's not info that the device itself is exposing, rather it's the driver: /and/ there's a pseudofile which identifes the kernel module implementing the driver.
Mark your code is impressive and a lot of thought has gone into it but it does not do the one thing I wouldl  like it t show me how to do? Which is send a string from pascal to the arduino and have the nano recognise that string then do the needful.

Now, what video did you want me to watch, or (even better) can you tell me the problems you're having interpreting things? Because right now I think that you're stuff because you're not making a distinction between "file" as defined by Pascal, and "file" as defined by the kernel... which in the case of unix (and I say unix advisedly, since I'm including SunOS etc.) has additional calls to set Baud rate, DTR state and so on which you're blithely ignoring.
I never ignored anything you sent 'blithely' or otherwise. I went through your code, was highly impressed at what you had done. Went through another couple of times looking for what I want to do and zilch. So saved your code for my own personal set of tools thinking this will come in handy someday.

So your pissed, so what else is new? Does not @Joanna  upset and piss your off much more? ( What is a friend for ?) and flattery I save for the fairer sex like our Joanna. I called it the way I saw it. That code was something else, but not what I was looking for is all.
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: MarkMLl on September 23, 2024, 04:15:32 pm
I'll try to come back to this in more detail later, but you could use the little terminal emulator program I gave you https://github.com/MarkMLl/serialcomms/blob/main/Term.pas as a starting point. Note the settings at the top for sped etc.

Looking specifically at (the source of) SerOpen(), I see that it sets one specific option that generic code won't use. In general you'd then set the line speed and put DTR/RTS in the correct state (neither of which you can do using generic file-handling code). also normal fpFlush() isn't appropriate so don't even try. You /could/ intercept the lower-level handlers so that WriteLn() etc. would talk to a serial port but trust me: you don't want to fiddle with that stuff.

MarkMLl
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Thaddy on September 23, 2024, 04:19:32 pm
I adapted the wiki in a way that is possibly acceptable to all:
https://wiki.freepascal.org/typed_files
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Aruna on September 23, 2024, 04:22:42 pm
Read my remark about portability: using the convenience functions is not portable.
Will do @Thaddy thanks.
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: rvk on September 23, 2024, 04:24:00 pm
You may want to reconsider that after watching this (https://www.google.com/search?sca_esv=445c9ec50e6b4223&sca_upv=1&sxsrf=ADLYWIIYWGUSwNLjQ4IBXxRFqKR01qcp4A:1727093150707&q=pascal+arduino&tbm=vid&source=lnms&fbs=AEQNm0CRraR4AFMOJtZDUPiZk_hDDcI2gsUCGe9dZxqjUB5Fjbg9g5Dvlwra67P-0Tq9xG3V6wtiiRWn3AMd3MwHGOtFdRgA2KD1bARv7g8btBn6Jlpu6imrEpstW2EY-NoR5DuL98FVdmK9OH0IsUWSs3kBQGNjkiv0KxcLJR6RW4EGB5adX2SRbewUlFeAZEE3zLI2szaVLCj1-4TxmjOoB-MtUkPttA&sa=X&ved=2ahUKEwjmvPetg9mIAxWXFzQIHS7rHqIQ0pQJegQIEBAB&biw=1680&bih=863&dpr=1#fpstate=ive&vld=cid:a6037fa6,vid:UfQIkNl7gKM,st:0)
Did you try the exact example mentioned in that video (but then with the USB port)?

You have TextFile and are sending complete strings while in that example just one letter is sent via a File of char.

Another possible problem... You close the /dev/ttyUSB0 port/file. This could reset things back. So you should not open and close it at the same place but keep a connection open. The downside of that could be that there could be done some buffering before flushing the data to that file/port so you might need to flush the data (or set the buffer to 0 or 1 before opening it as file).


Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Aruna on September 23, 2024, 05:33:39 pm
You may want to reconsider that after watching this (https://www.google.com/search?sca_esv=445c9ec50e6b4223&sca_upv=1&sxsrf=ADLYWIIYWGUSwNLjQ4IBXxRFqKR01qcp4A:1727093150707&q=pascal+arduino&tbm=vid&source=lnms&fbs=AEQNm0CRraR4AFMOJtZDUPiZk_hDDcI2gsUCGe9dZxqjUB5Fjbg9g5Dvlwra67P-0Tq9xG3V6wtiiRWn3AMd3MwHGOtFdRgA2KD1bARv7g8btBn6Jlpu6imrEpstW2EY-NoR5DuL98FVdmK9OH0IsUWSs3kBQGNjkiv0KxcLJR6RW4EGB5adX2SRbewUlFeAZEE3zLI2szaVLCj1-4TxmjOoB-MtUkPttA&sa=X&ved=2ahUKEwjmvPetg9mIAxWXFzQIHS7rHqIQ0pQJegQIEBAB&biw=1680&bih=863&dpr=1#fpstate=ive&vld=cid:a6037fa6,vid:UfQIkNl7gKM,st:0)
Did you try the exact example mentioned in that video (but then with the USB port)?
Hello @rvk, yes I followed his steps to the letter. I am going to do it over again from scratch and will post a video so anyone interested can see.

You have TextFile and are sending complete strings while in that example just one letter is sent via a File of char.

Another possible problem... You close the /dev/ttyUSB0 port/file. This could reset things back. So you should not open and close it at the same place but keep a connection open. The downside of that could be that there could be done some buffering before flushing the data to that file/port so you might need to flush the data (or set the buffer to 0 or 1 before opening it as file).
Yes I was trying to send 'more' than a single character like on/off. I have no idea how to keep a connection open :-( Thank you for the guidance.
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: MarkMLl on September 23, 2024, 05:35:22 pm
Yes please. Pay attention at 3:40 then again at 7:50 please and thank you. His code works as we can see in that video but when I try and type in the exact same code it chokes on me?

As RVK says, the demo code (7:42 in the video) runs forever without terminating and in particular without closing the connection. It also makes lots of assumptions about the speed that the port is set to by default, the state of (in particular) DTR and so on.

Your code similarly makes assumptions about speed and so on: but on a different OS where those assumptions are not at all safe. You send multiple characters and assume that they have all been transmitted before the file is closed, but even if the program or OS used flush() at the handle level (i.e. fpFlush() in the RTL) that call is ineffective on a serial port: it's one of the reasons why I got involved with maintenance of the serial unit in the first place and I direct you to

Code: Pascal  [Select][+][-]
  1. { Flushes the data queues of the given serial device. DO NOT USE THIS:
  2.   use either SerSync (non-blocking) or SerDrain (blocking). }
  3. procedure SerFlush(Handle: TSerialHandle); deprecated;
  4.  

And so on.

Now, you've been spinning your wheels on this one since before the weekend: stop wasting your time and everybody else's and look at the example that I sent you. Or use SynAsync or whatever, noting that that's explicitly been written to be "further from the metal" than serial.pp.

MarkMLl
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: rvk on September 23, 2024, 07:12:23 pm
It also makes lots of assumptions about the speed that the port is set to by default, the state of (in particular) DTR and so on.
Connecting via usb would be standard and there would be no need for speed etc. But the arduino should also be programmed to receive it correctly.

@Aruna you also might want to show the other side (arduino code) because in the given video there is only character per character read (and not even from usb). And you might give some more information about how you connect both sides.
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: MarkMLl on September 23, 2024, 07:41:48 pm
It also makes lots of assumptions about the speed that the port is set to by default, the state of (in particular) DTR and so on.
Connecting via usb would be standard and there would be no need for speed etc. But the arduino should also be programmed to receive it correctly.

That's not the point I'm making. My point is that on Windows I /think/ that a serial port starts off in a known state and is restored to that state by the OS, while in unix- at least Linux but I believe others as well- the speed and signal state are /not/ normally changed by the OS... that's where the setserial command comes into it, at least for some port types.

And the convention that the OS does not meddle with the speed ties in with the convention that the serial port is /not/ opened exclusively, which goes back to how a getty works: it monitors a serial line and expects some form of user identification, after which it fires up either the login program (to read and validate a password) or e.g. a handler for an incoming fax. But in either case it stays running in the background with a handle for the serial line, and does not expect anything to permanently mess that up by e.g. changing the speed.

So a standalone program cannot ever assume that the speed and modem control lines are in a sane state: if dictated by its function, it has to set them explicitly.

And that's also why SerOpen() in serial.pp doesn't attempt to get an exclusive lock on the port it's opening. However in retrospect I regret that choice, and would prefer to e.g. have an SerOpenLocked:Boolean=true global or possibly an extra parameter to SerOpen(). But I'm not going to try adding it because (a) I don't relish getting involved with Git and (b) I'm no longer in a position to test thoroughly on a relatively-recent Windows and on a BSD-style unix.

MarkMLl
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Aruna on September 23, 2024, 08:07:58 pm
@Aruna you also might want to show the other side (arduino code) because in the given video there is only character per character read (and not even from usb). And you might give some more information about how you connect both sides.
Hi @rvk thank you for making me go over this again. I just found out what the problem is and your gonna have some serious fun with it when I disclose after I rustle up some grub because I am famished. Will be back in a bit. Your never going to believe what is happening with my nano :-)
Title: Re: Error: Wrong number of parameters specified for call to "Assign"
Post by: Joanna from IRC on September 24, 2024, 06:25:22 am
Quote
So your pissed, so what else is new? Does not @Joanna  upset and piss your off much more? ( What is a friend for ?) and flattery I save for the fairer sex like our Joanna. I called it the way I saw it. That code was something else, but not what I was looking for is all.
Wow.. ok can anyone guess why I keep suggesting that people who don’t know pascal should not be allowed to post in the support part of these  forums?  >:D
TinyPortal © 2005-2018