]> git.tdb.fi Git - model-railway-devices.git/commitdiff
Give each MFX command its own feedback packet type
authorMikko Rasa <tdb@tdb.fi>
Fri, 8 Nov 2013 18:41:28 +0000 (20:41 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 8 Nov 2013 18:41:28 +0000 (20:41 +0200)
arducontrol/commands.h
arducontrol/mfx.c

index 1fd027c112f6159eb5531cea80913933874ea8d5..3b7597c0a43f5c3f9591edb37bc17924ab02dc61 100644 (file)
@@ -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
index 293765fba9d7c8933106e48c6cdbc5ab4923cfa2..8c46fc3123cf40d16ac3fc9f56c74eff7989d70e 100644 (file)
@@ -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)