mirror of
https://github.com/halleysfifthinc/AVCLAN-Mockingboard.git
synced 2026-08-07 01:13:18 +00:00
Improve action/function names and tweak report responses
This commit is contained in:
+41
-21
@@ -79,7 +79,7 @@
|
|||||||
A bit `0` is dominant on the bus, which is a design choice that affects
|
A bit `0` is dominant on the bus, which is a design choice that affects
|
||||||
bit/interpretation:
|
bit/interpretation:
|
||||||
- Low addresses have priority upon transmission conflicts
|
- Low addresses have priority upon transmission conflicts
|
||||||
- The broadcast bit is `1` for normal communication
|
- The broadcast bit is `1` (floating, no effort) for normal communication
|
||||||
- For acknowledge bits, the receiver extends the logical '0' of the sync
|
- For acknowledge bits, the receiver extends the logical '0' of the sync
|
||||||
period to the length of a normal bit `0`. Hence, a NAK (bit `1`) is
|
period to the length of a normal bit `0`. Hence, a NAK (bit `1`) is
|
||||||
equivalent to no response.
|
equivalent to no response.
|
||||||
@@ -157,15 +157,23 @@ uint16_t period = 0;
|
|||||||
uint16_t pulsewidth;
|
uint16_t pulsewidth;
|
||||||
|
|
||||||
// answers
|
// answers
|
||||||
uint8_t lancheck_resp[] = {0x00, 0x01, 0x00, 0xFF};
|
uint8_t lancheck_resp[] = {0x00, 0x01, 0x00, 0xFF, 0xFF};
|
||||||
const uint8_t list_functions_resp[] = {0x00, dev_COMM_CTRL, dev_COMM_v1,
|
const uint8_t list_functions_resp[] = {0x00, dev_COMM_CTRL, dev_COMM_v1,
|
||||||
List_Functions_Resp, dev_CD_CHANGER};
|
List_Functions_Resp, dev_CD_CHANGER};
|
||||||
uint8_t ping_resp[] = {0x00, dev_COMM_CTRL, dev_COMM_v1, Ping_Resp, 0xFF, 0x00};
|
uint8_t ping_resp[] = {0x00, dev_COMM_CTRL, dev_COMM_v1, Ping_Resp, 0xFF, 0x00};
|
||||||
uint8_t function_change_resp[] = {0x00, dev_CD_CHANGER, dev_COMM_v1, 0xFF,
|
uint8_t function_change_resp[] = {0x00, dev_CD_CHANGER, dev_COMM_v1, 0xFF,
|
||||||
0x01};
|
0x01};
|
||||||
uint8_t cdstatus_resp[] = {
|
uint8_t cdstatus_resp[] = {dev_CD_CHANGER,
|
||||||
dev_CD_CHANGER, dev_STATUS, Report, 0x01, cd_SEEKING_TRACK, 0x01, 0x00,
|
dev_STATUS,
|
||||||
0xFF, 0x7F, 0x00, 0xc0};
|
Status_Report,
|
||||||
|
0x01,
|
||||||
|
cd_SEEKING_TRACK,
|
||||||
|
0x01,
|
||||||
|
0x00,
|
||||||
|
0xFF,
|
||||||
|
0x7F,
|
||||||
|
0x00,
|
||||||
|
0x80};
|
||||||
|
|
||||||
uint8_t AVCLAN_handleframe(const AVCLAN_frame_t *frame);
|
uint8_t AVCLAN_handleframe(const AVCLAN_frame_t *frame);
|
||||||
void AVCLAN_updateCDStatus();
|
void AVCLAN_updateCDStatus();
|
||||||
@@ -789,6 +797,8 @@ const AVCLAN_frame_t *qPop() {
|
|||||||
uint8_t AVCLAN_handleframe(const AVCLAN_frame_t *frame) {
|
uint8_t AVCLAN_handleframe(const AVCLAN_frame_t *frame) {
|
||||||
uint8_t respond = 0;
|
uint8_t respond = 0;
|
||||||
AVCLAN_frame_t *resp = malloc(sizeof(AVCLAN_frame_t));
|
AVCLAN_frame_t *resp = malloc(sizeof(AVCLAN_frame_t));
|
||||||
|
uint8_t from;
|
||||||
|
uint8_t to;
|
||||||
|
|
||||||
if (!resp)
|
if (!resp)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -796,36 +806,43 @@ uint8_t AVCLAN_handleframe(const AVCLAN_frame_t *frame) {
|
|||||||
resp->controller_addr = DEVICE_ADDR;
|
resp->controller_addr = DEVICE_ADDR;
|
||||||
resp->control = 0xF;
|
resp->control = 0xF;
|
||||||
|
|
||||||
|
// BROADCAST (1 is UNICAST)
|
||||||
if (!frame->broadcast) {
|
if (!frame->broadcast) {
|
||||||
// peripheral_addr will be 0xFFF or 0x1FF based on all currently known
|
// peripheral_addr will be 0xFFF or 0x1FF based on all currently known
|
||||||
// examples
|
// examples
|
||||||
// if (frame->peripheral_addr == 0xFFF || frame->peripheral_addr == 0x1FF) {
|
// if (frame->peripheral_addr == 0xFFF || frame->peripheral_addr == 0x1FF) {
|
||||||
if (frame->data[0] == 0) {
|
from = frame->data[0];
|
||||||
if (frame->data[1] == dev_COMM_CTRL) {
|
if (from == 0) {
|
||||||
|
to = frame->data[1];
|
||||||
|
if (to == dev_COMM_CTRL) {
|
||||||
switch (frame->data[2]) {
|
switch (frame->data[2]) {
|
||||||
case Lancheck_Scan_Req:
|
case Lancheck_Scan_Req:
|
||||||
lancheck_resp[3] = Lancheck_Scan_Resp;
|
lancheck_resp[3] = Lancheck_Scan_Resp;
|
||||||
|
lancheck_resp[4] = 0x01;
|
||||||
|
resp->length = sizeof(lancheck_resp);
|
||||||
goto GROUPED;
|
goto GROUPED;
|
||||||
case Lancheck_Req:
|
case Lancheck_Req:
|
||||||
lancheck_resp[3] = Lancheck_Resp;
|
lancheck_resp[3] = Lancheck_Resp;
|
||||||
|
lancheck_resp[4] = 0x00;
|
||||||
|
resp->length = sizeof(lancheck_resp);
|
||||||
goto GROUPED;
|
goto GROUPED;
|
||||||
case Lancheck_End_Req:
|
case Lancheck_End_Req:
|
||||||
lancheck_resp[3] = Lancheck_End_Resp;
|
lancheck_resp[3] = Lancheck_End_Resp;
|
||||||
|
resp->length = sizeof(lancheck_resp) - 1;
|
||||||
goto GROUPED;
|
goto GROUPED;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
GROUPED:
|
GROUPED:
|
||||||
resp->broadcast = UNICAST;
|
resp->broadcast = UNICAST;
|
||||||
resp->peripheral_addr = HU_ADDR;
|
resp->peripheral_addr = HU_ADDR;
|
||||||
resp->length = sizeof(lancheck_resp);
|
|
||||||
resp->data = (uint8_t *)lancheck_resp;
|
resp->data = (uint8_t *)lancheck_resp;
|
||||||
respond = 1;
|
respond = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (frame->data[0] == dev_COMM_v1) {
|
} else if (from == dev_COMM_v1) {
|
||||||
if (frame->data[1] == dev_COMM_CTRL) {
|
if (to == dev_COMM_CTRL) {
|
||||||
switch (frame->data[2]) {
|
switch (frame->data[2]) {
|
||||||
case Advertise_Function:
|
case Current_Function:
|
||||||
if (frame->data[3] == dev_CD_CHANGER)
|
if (frame->data[3] == dev_CD_CHANGER)
|
||||||
CD_Mode = stPlay;
|
CD_Mode = stPlay;
|
||||||
else
|
else
|
||||||
@@ -854,8 +871,10 @@ uint8_t AVCLAN_handleframe(const AVCLAN_frame_t *frame) {
|
|||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
} else if (frame->peripheral_addr == DEVICE_ADDR) { // unicast to CD changer
|
} else if (frame->peripheral_addr == DEVICE_ADDR) { // unicast to CD changer
|
||||||
if (frame->data[0] == 0) {
|
from = frame->data[0];
|
||||||
switch (frame->data[1]) {
|
if (from == 0) {
|
||||||
|
to = frame->data[1];
|
||||||
|
switch (to) {
|
||||||
case dev_COMM_v1:
|
case dev_COMM_v1:
|
||||||
switch (frame->data[2]) {
|
switch (frame->data[2]) {
|
||||||
case dev_CD_CHANGER:
|
case dev_CD_CHANGER:
|
||||||
@@ -878,7 +897,7 @@ uint8_t AVCLAN_handleframe(const AVCLAN_frame_t *frame) {
|
|||||||
answerReq = cm_CDStatus;
|
answerReq = cm_CDStatus;
|
||||||
goto GROUPED2;
|
goto GROUPED2;
|
||||||
// case 0x80:
|
// case 0x80:
|
||||||
// act = Inserted_CD;
|
// act = Insertion;
|
||||||
// goto GROUPED;
|
// goto GROUPED;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -896,18 +915,19 @@ uint8_t AVCLAN_handleframe(const AVCLAN_frame_t *frame) {
|
|||||||
case dev_STATUS:
|
case dev_STATUS:
|
||||||
if (frame->data[2] == dev_CD_CHANGER) {
|
if (frame->data[2] == dev_CD_CHANGER) {
|
||||||
switch (frame->data[3]) {
|
switch (frame->data[3]) {
|
||||||
case Request_Report:
|
case Initial_Report_Request:
|
||||||
cdstatus_resp[2] = Report;
|
cdstatus_resp[2] = Initial_Report_Response;
|
||||||
goto GROUPED3;
|
goto GROUPED3;
|
||||||
case Request_Report2:
|
case Playback_Request:
|
||||||
cdstatus_resp[2] = Report2;
|
cdstatus_resp[2] = Playback_Report;
|
||||||
goto GROUPED3;
|
goto GROUPED3;
|
||||||
case Request_Loader2:
|
case Loading_Request2:
|
||||||
cdstatus_resp[2] = Report_Loader2;
|
cdstatus_resp[2] = Loading_Response2;
|
||||||
goto GROUPED3;
|
goto GROUPED3;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
GROUPED3:
|
GROUPED3:
|
||||||
|
cdstatus_resp[2] = to; // respond to device that requested
|
||||||
memcpy(&cdstatus_resp[3], &cd_status, sizeof(cd_status));
|
memcpy(&cdstatus_resp[3], &cd_status, sizeof(cd_status));
|
||||||
resp->broadcast = BROADCAST;
|
resp->broadcast = BROADCAST;
|
||||||
resp->peripheral_addr = 0x1FF;
|
resp->peripheral_addr = 0x1FF;
|
||||||
@@ -1050,7 +1070,7 @@ void AVCLAN_updateCDStatus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (answerReq == cm_CDStatus) {
|
if (answerReq == cm_CDStatus) {
|
||||||
cdstatus_resp[2] = Report;
|
cdstatus_resp[2] = Status_Report;
|
||||||
memcpy(&cdstatus_resp[3], &cd_status, sizeof(cd_status));
|
memcpy(&cdstatus_resp[3], &cd_status, sizeof(cd_status));
|
||||||
|
|
||||||
AVCLAN_frame_t status = {.broadcast = BROADCAST,
|
AVCLAN_frame_t status = {.broadcast = BROADCAST,
|
||||||
|
|||||||
+17
-13
@@ -90,10 +90,11 @@ typedef enum {
|
|||||||
Disable_Function_Req = 0x43,
|
Disable_Function_Req = 0x43,
|
||||||
Disable_Function_Resp = 0x53,
|
Disable_Function_Resp = 0x53,
|
||||||
|
|
||||||
Advertise_Function = 0x45,
|
Current_Function = 0x45,
|
||||||
General_Query = 0x46,
|
General_Query = 0x46,
|
||||||
|
|
||||||
// Physical interface
|
// Physical interface
|
||||||
|
Backlight_Adjust = 0x59,
|
||||||
Eject = 0x80,
|
Eject = 0x80,
|
||||||
Disc_Up = 0x90,
|
Disc_Up = 0x90,
|
||||||
Disc_Down = 0x91,
|
Disc_Down = 0x91,
|
||||||
@@ -108,24 +109,27 @@ typedef enum {
|
|||||||
CD_Enable_Random = 0xb0,
|
CD_Enable_Random = 0xb0,
|
||||||
CD_Disable_Random = 0xb1,
|
CD_Disable_Random = 0xb1,
|
||||||
|
|
||||||
// CD functions
|
|
||||||
// Events
|
// Events
|
||||||
Inserted_CD = 0x50,
|
Insertion = 0x50,
|
||||||
Removed_CD = 0x51,
|
Ejection = 0x51,
|
||||||
|
|
||||||
|
// Requests and Response pairs
|
||||||
|
Initial_Report_Request = 0xe0,
|
||||||
|
Initial_Report_Response = 0xf0,
|
||||||
|
|
||||||
|
Playback_Request = 0xe2,
|
||||||
|
Playback_Report = 0xf2,
|
||||||
|
|
||||||
|
Loading_Request2 = 0xe4,
|
||||||
|
Loading_Response2 = 0xf4,
|
||||||
|
|
||||||
// Requests
|
|
||||||
Request_Report = 0xe0,
|
|
||||||
Request_Report2 = 0xe2,
|
|
||||||
Request_Loader2 = 0xe4,
|
|
||||||
Request_Track_Name = 0xed,
|
Request_Track_Name = 0xed,
|
||||||
|
Report_Track_Name = 0xfd,
|
||||||
|
|
||||||
// Reports
|
// Reports
|
||||||
Report = 0xf1,
|
Status_Report = 0xf1, // Typically unprompted, sent to dev_STATUS
|
||||||
Report2 = 0xf2,
|
Loading_Status_Report = 0xf3, // Typically unprompted, sent to dev_STATUS
|
||||||
Report_Loader = 0xf3,
|
|
||||||
Report_Loader2 = 0xf4,
|
|
||||||
Report_TOC = 0xf9,
|
Report_TOC = 0xf9,
|
||||||
Report_Track_Name = 0xfd,
|
|
||||||
} actions;
|
} actions;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|||||||
Reference in New Issue
Block a user