Communication issue with TinyG

Home Forums TinyG TinyG Support Communication issue with TinyG

Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
    Posts
  • #7779
    enhering
    Member

    You mean a blocking read? I will try that then.

    How long should I wait to read after writing? Can it be consecutive?

    Edit: I usually read until a \n. I can also read until the buffer is empty, but I’m afraid this can mix messages on a race condition.

    • This reply was modified 9 years, 3 months ago by enhering.
    #7781
    cmcgrath5035
    Moderator

    You mean a blocking read?

    I’m not exactly sure what you mean by a blocking read.

    Over in CP space, we send commands in json mode, wait for the the confirming json status response before proceeding.

    #7793
    jlauer
    Member

    enhering, one thing to consider is possibly using Serial Port JSON Server behind your app and just having your GUI connect to it. The reason is that a lot of work is being done to solve lots of nitty gritty problems that you are running into. If you don’t want to have to reinvent all that work, this could possibly be a better way to go.

    Here’s a quick list of some top things SPJS solves for TinyG:
    1. Buffer flow algorithm that works perfectly for TinyG
    2. New buffer flow algorithm that works perfectly for TinyG G2 (the new Arduino Due dual port version)
    3. USB info traversal to figure out the related dual ports for item 2.
    4. Programming ability for any Atmel chip, i.e. any Arduino or TinyG, courtesy of the Arduino guys actually contributing code to SPJS so that you can upgrade the firmware of the CNC controller without any extra work.

    #7808
    enhering
    Member

    Hi jlauer and Moderator!

    Thank you for the suggestions. I’ll think about them. I just won’t change anything now because the code is working well. I could solve the problems that were holding me back and the GCode is being sent to the CNC respecting the queue buffer size and the rx buffer size. I can monitor the log while the job is done and now I see no issues.

    I have also finished implementing a simple GCode translator using boost::regex to turn a laser on and off every time I get a Z+xx or a Z-xx instruction. As I connected the laser driver TTL input to the coolant port of TinyG, I can use this translation to drive the laser on and off while sending a PCB design to the machine. I plan to use the laser to burn a black ink layer over the PCB and, then, to drill the PCB holes and cuts using the spindle.

    If I run into more communications trouble I’ll seriously consider using JSON server. If not, I’ll keep using my own libraries.

    Regarding the reply from the moderator, my serial reading function blocks the program execution until it finds a specified character, in my case a \n. Another reading function blocks execution until the nothing is left to be read. As they hold the execution until the condition is satisfied (or a timeout is reached), they are considered blocking reads.

    I also have not invested any time in a GUI. I used ncurses for a very, very simple text mode interface with one key menu options that control the machine, file sending, laser mode, simulation mode, offset control etc. The most comfortable characteristic of my solution (for me) is that I can control what, and in which order, I send to the machine in the setup cycle. And I can follow the ins and outs from the log file, with microsecond resolution delay measurements.

    I am not rejecting your solutions. I just move faster developing the needed solutions in my own code. In this case, I’m using the serial communication libraries that I developed (or customised) for other micro controller projects or for communicating with laboratory instrumentation. But the regex modules came from boost and the JSON parser came from libJSON.

    Thanks again for your help, your time and your consideration.

    #7810
    cmcgrath5035
    Moderator

    OK, I now better understand your “blocking read” definition and implementation.

    Suggestion: be mindful of the tinyG settings that you are programming to.
    For example, does the setting of $tv text verbosity affect the characters you are waiting to see?
    The values set for $tv, $js and $jv will affect what tinyG sends back to your program.

    Good luck with your project!

Viewing 5 posts - 16 through 20 (of 20 total)
  • You must be logged in to reply to this topic.