From 5d6f425971266accc2e3d1c6de96a0ba031adb8d Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 8 Nov 2013 20:41:28 +0200 Subject: [PATCH] Give each MFX command its own feedback packet type --- arducontrol/commands.h | 3 ++- arducontrol/mfx.c | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arducontrol/commands.h b/arducontrol/commands.h index 1fd027c..3b7597c 100644 --- a/arducontrol/commands.h +++ b/arducontrol/commands.h @@ -34,7 +34,8 @@ enum Command INPUT_VOLTAGE = 0xC1, POWER_STATE = 0xC2, S88_DATA = 0xD0, - MFX_FEEDBACK = 0xD1 + MFX_SEARCH_FEEDBACK = 0xD1, + MFX_PING_FEEDBACK = 0xD2 }; #endif diff --git a/arducontrol/mfx.c b/arducontrol/mfx.c index 293765f..8c46fc3 100644 --- a/arducontrol/mfx.c +++ b/arducontrol/mfx.c @@ -235,7 +235,7 @@ static void mfx_finish_packet_feedback(OutputPacket *packet, MfxEncodingState *s packet->final_delay = 128; } -static void mfx_receive_feedback() +static void mfx_receive_feedback(uint8_t type) { /* The decoder should activate a 52.6 kHz carrier to indicate positive acknowledgement, but so far I've been unable to build a circuit that detects @@ -255,7 +255,7 @@ static void mfx_receive_feedback() } uint8_t reply[2]; - reply[0] = MFX_FEEDBACK; + reply[0] = type; if(current[1]>feedback_threshold) { current[1] -= feedback_threshold; @@ -391,7 +391,7 @@ uint8_t mfx_command(const uint8_t *cmd, uint8_t length) mask_bits <<= 16; mask_bits |= (uint16_t)(cmd[3]<<8)|cmd[4]; mfx_search_packet(mask_bits, mask_size); - mfx_receive_feedback(); + mfx_receive_feedback(MFX_SEARCH_FEEDBACK); } else if(cmd[0]==MFX_ASSIGN_ADDRESS || cmd[0]==MFX_PING) { @@ -410,7 +410,7 @@ uint8_t mfx_command(const uint8_t *cmd, uint8_t length) else { mfx_ping_packet(addr, id); - mfx_receive_feedback(); + mfx_receive_feedback(MFX_PING_FEEDBACK); } } else if(cmd[0]==MFX_SPEED || cmd[0]==MFX_SPEED_FUNCS8 || cmd[0]==MFX_SPEED_FUNCS16) -- 2.45.2