Index: lab4/errors.h
===================================================================
--- lab4/errors.h	(revision 69)
+++ lab4/errors.h	(revision 70)
@@ -2,15 +2,16 @@
 #define ERRORS_H_INCLUDED
 
 enum errors {
-    SUCCESS = 0,    /* @brief Sucessful */
-    NULL_PTR,       /* @brief Null Pointer Error */
-    LCF_ERROR,      /* @brief Error originated on LCF */
-    SBCR_ERROR,     /* @brief Error on Subscribing Interrupt */
-    UNSBCR_ERROR,   /* @brief Error on Unsubscring Interrupt*/
-    READ_ERROR,     /* @brief Error on Reading from Port */
-    WRITE_ERROR,    /* @brief Error on Writing to Port */
-    TIMEOUT_ERROR,  /* @brief Timeout error */
-    OTHER_ERROR,    /* @brief Unspecified error */
+    SUCCESS = 0,        /* @brief Sucessful */
+    NULL_PTR,           /* @brief Null Pointer Error */
+    LCF_ERROR,          /* @brief Error originated on LCF */
+    SBCR_ERROR,         /* @brief Error on Subscribing Interrupt */
+    UNSBCR_ERROR,       /* @brief Error on Unsubscring Interrupt*/
+    READ_ERROR,         /* @brief Error on Reading from Port */
+    WRITE_ERROR,        /* @brief Error on Writing to Port */
+    TIMEOUT_ERROR,      /* @brief Timeout error */
+    INVALID_COMMAND,    /* @brief Invalid Command issued */
+    OTHER_ERROR,        /* @brief Unspecified error */
 };
 
 #endif //ERRORS_H_INCLUDED
Index: lab4/lab4.c
===================================================================
--- lab4/lab4.c	(revision 69)
+++ lab4/lab4.c	(revision 70)
@@ -5,6 +5,8 @@
 
 #include "mouse.h"
 #include "kbc.h"
+#include "errors.h"
+#include "mouse_macros.h"
 
 int main(int argc, char *argv[]) {
   // sets the language of LCF messages (can be either EN-US or PT-PT)
@@ -80,9 +82,46 @@
 }
 
 int (mouse_test_remote)(uint16_t period, uint8_t cnt) {
-    /* To be completed */
-    printf("%s(%u, %u): under construction\n", __func__, period, cnt);
-    return 1;
+
+    // Mouse packets data
+    uint8_t packet[3];
+    int sz = 0;
+    uint8_t data = 0;
+    // Cycle
+    int packetCounter = 0;
+    int good = 1;
+    // return value
+    int ret;
+
+    while (good) {
+
+        if ((ret = mouse_read_data(&data))) return ret;
+
+        if ((data & FIRST_BYTE_ID) || sz) {
+            packet[sz] = data;
+            sz++;
+        }
+
+        if (sz == 3) {
+            struct packet pp = mouse_parse_packet(packet);
+            mouse_print_packet(&pp);
+            packetCounter++;
+            sz = 0;
+            if (packetCounter == cnt) good = 0;
+        }
+
+        tickdelay(micros_to_ticks(period*1e3));
+    }
+
+    // Set Stream mode
+    if ((ret = mouse_issue_cmd(SET_STREAM_MD))) return ret;
+    // Disable data reporting
+    if ((ret = mouse_issue_cmd(DIS_DATA_REP))) return ret;
+
+    uint8_t cmd_byte = minix_get_dflt_kbc_cmd_byte();
+    if ((ret = kbc_change_cmd(cmd_byte))) return ret;
+
+    return SUCCESS;
 }
 
 int (mouse_test_async)(uint8_t idle_time) {
Index: lab4/mouse.c
===================================================================
--- lab4/mouse.c	(revision 69)
+++ lab4/mouse.c	(revision 70)
@@ -66,3 +66,38 @@
     printf("ACK: %x\n", ack);
     return SUCCESS;
 }
+
+int (mouse_read_data)(uint8_t *data) {
+    int ret;
+    if ((ret = mouse_issue_cmd(READ_DATA))) return ret;
+    if ((ret = mouse_read_byte(data))) return ret;
+    return SUCCESS;
+}
+
+int (mouse_issue_cmd)(uint32_t cmd) {
+    int ret;
+    uint8_t ack = 0;
+    while (ack != ACK_ERROR) {
+        if ((ret = kbc_issue_cmd(MOUSE_WRITE_B))) return ret;
+        if ((ret = kbc_issue_arg(cmd))) return ret;
+        if ((ret = mouse_read_byte(&ack))) return ret;
+        if (ack == ACK_OK) return SUCCESS;
+        tickdelay(micros_to_ticks(DELAY));
+    }
+    return INVALID_COMMAND;
+}
+
+int (mouse_read_byte)(uint8_t *byte) {
+    int ret = 0;
+    uint8_t stat;
+    for(int i = 0; i < KBC_NUM_TRIES; ++i){
+        if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;
+        if((stat&OUT_BUF_FUL) && (stat&AUX_MOUSE)) {
+            if(stat & (PARITY_ERROR | TIME_OUT_REC)) return OTHER_ERROR;
+            if((ret = util_sys_inb(OUTPUT_BUF, byte))) return ret;
+            else return SUCCESS;
+        }
+        tickdelay(micros_to_ticks(DELAY));
+    }
+    return TIMEOUT_ERROR;
+}
Index: lab4/mouse.h
===================================================================
--- lab4/mouse.h	(revision 69)
+++ lab4/mouse.h	(revision 70)
@@ -16,4 +16,36 @@
 
 int (mouse_set_data_report)(int on);
 
+/**
+ * @brief Reads data byte from mouse
+ * <summary>
+ * Polls the mouse till data is available for reading
+ * </summary>
+ * @param data Pointer to variable where byte read from mouse will be stored
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ * @see {_ERRORS_H_::errors}
+ */
+int (mouse_read_data)(uint8_t *data);
+
+/**
+ * @brief Issues command to mouse
+ * <summary>
+ * Issues command to mouse, returns error after two consecutive errors reported by the acknowledgment byte
+ * </summary>
+ * @param cmd Command to be issued
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ * @see {_ERRORS_H_::errors}
+ */
+int (mouse_issue_cmd)(uint32_t cmd);
+
+/**
+ * @brief Reads byte from mouse
+ * <summary>
+ * Reads byte from mouse, giving error if exceeds number of tries to read
+ * @param byte Pointer to variable where byte read from mouse will be stored
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ * @see {_ERRORS_H_::errors}
+ */
+int (mouse_read_byte)(uint8_t *byte);
+
 #endif //MOUSE_H_INCLUDED
