New implementation fo main loop. Now using REQUEST_DEVICE command for any write operation