KurtE
Senior Member+
Quick background: I am playing around with my own board, that semi emulates a Trossen Robotics Arbotix-Pro which emulates a Robotis CM-730 controller.
What is basically does is to receive packets from the host like a PC or a linux board such as an Raspberry pi or Odroid...
With PC's it uses USB port, but with Linux boards I am setting up to use TTL serial (experimenting currently at 2mbs)
What it basically does is receive a packet from the host, that looks something like: 0xff 0xff <id> <length> ... <chksum>. The board itself has it's own logical ID and if the packet is addressed to board it responds, else it sends the packet out the Dynamixel Buss (Half duplex 1mbs), and if it receives anything back from the target, it forwards the response to the host. A goal is to minimize the time it takes for the host to send a packet and get the response back.
At the simplest code if we disregard the packets we intercept a main loop may look something like:
Which can work fine in the basic case. There is also some other stuff going on, like checking voltages to see if the battery is going low, or maybe checking the state of an IMU...
But I am trying to decide between two different approaches here.
Currently the code works as a state machine, where it looks for the: 0xff 0xff <ID> and sees if the ID is for the board. If so it does not output any of this packet over the AX Buss. (This works like some other controllers, I have looked at incluing USBTOAX. So at best, the AX Buss will be at least three characters behind the Host for those packets not meant for the board.
The Arbotix-pro/CM730 does this different. They forward all of the bytes from the host to the AXBUS, and they do this within the interrupt handler. The plus of this is that a delay is about one character, and this happens regardless if I am busy doing something else. But the downside is we are sending more data over the AX-BUS, which most of the time is not really an issue, but in some small cases, might slow how fast I can retrieve data from the board. But probably not that major of a downside.
So the question is, suppose I wish to go the second route. Is there an any easy way to do this level of data forwarding at the interrupt time, preferably without having to write my own interrupt handlers?
Thanks
What is basically does is to receive packets from the host like a PC or a linux board such as an Raspberry pi or Odroid...
With PC's it uses USB port, but with Linux boards I am setting up to use TTL serial (experimenting currently at 2mbs)
What it basically does is receive a packet from the host, that looks something like: 0xff 0xff <id> <length> ... <chksum>. The board itself has it's own logical ID and if the packet is addressed to board it responds, else it sends the packet out the Dynamixel Buss (Half duplex 1mbs), and if it receives anything back from the target, it forwards the response to the host. A goal is to minimize the time it takes for the host to send a packet and get the response back.
At the simplest code if we disregard the packets we intercept a main loop may look something like:
Code:
void loop() {
int data;
if ((data = Serial1.read()) != -1)
Serial2.write(data);
if ((data = Serial2.read()) != -1)
Serial1.write(data);
}
But I am trying to decide between two different approaches here.
Currently the code works as a state machine, where it looks for the: 0xff 0xff <ID> and sees if the ID is for the board. If so it does not output any of this packet over the AX Buss. (This works like some other controllers, I have looked at incluing USBTOAX. So at best, the AX Buss will be at least three characters behind the Host for those packets not meant for the board.
The Arbotix-pro/CM730 does this different. They forward all of the bytes from the host to the AXBUS, and they do this within the interrupt handler. The plus of this is that a delay is about one character, and this happens regardless if I am busy doing something else. But the downside is we are sending more data over the AX-BUS, which most of the time is not really an issue, but in some small cases, might slow how fast I can retrieve data from the board. But probably not that major of a downside.
So the question is, suppose I wish to go the second route. Is there an any easy way to do this level of data forwarding at the interrupt time, preferably without having to write my own interrupt handlers?
Thanks