Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

access to serial port linux #74

Open
arblake opened this issue Feb 28, 2021 · 1 comment
Open

access to serial port linux #74

arblake opened this issue Feb 28, 2021 · 1 comment

Comments

@arblake
Copy link

arblake commented Feb 28, 2021

Not a bug but use difficulty
I wish to access the serial port on linux.
I tried this, what is wrong?

variable serid
9600 constant baudrate
create buf 59 cells allot
0 open-com serid swap !
buf 25 100 serid @ timed-read-com

The device sends a string ever second.

@MitchBradley
Copy link
Owner

  • I don't understand the "swap" after open-com . The stack diagram for ! is ( n address -- )
  • Your code has no error check of the value returned by open-com . If the return value is -1, the operation failed. I do not know whether or not that happened, from what you report.
  • As an alternative to "create buf 59 cells allot", it is better to allocate buffers with "59 cells buffer: buf" . That works better for code that will ultimately be compiled, because the space is dynamically allocated as needed, instead of going in the dictionary, which might be partially in read-only FLASH on some systems.
  • timed-read-com returns the number of bytes actually received. If the operation times out without having received any bytes, timed-read-com returns 0. You did not say what value timed-read-com returned, so I cannot tell what it did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants