Hi all
I am trying to serial.device unit 1 at 38400 baud and I am trying to send commands to it, but following code should shutdown A1222, but nothing happens. What am I doing wrong ?
(I used serial device example on AmigaOS4 Wiki)
#include <exec/types.h> #include <exec/memory.h> #include <exec/io.h> #include <devices/serial.h> #include <proto/exec.h> #include <proto/dos.h> int main() { struct MsgPort *SerialMP = IExec->AllocSysObjectTags(ASOT_PORT, TAG_END); /* Create the message port */ if (SerialMP != NULL) { /* Create the IORequest */ struct IOExtSer *SerialIO = IExec->AllocSysObjectTags(ASOT_IOREQUEST, ASOIOR_ReplyPort, SerialMP, ASOIOR_Size, sizeof(struct IOExtSer), TAG_END); if (SerialIO != NULL) { /* Open the serial device */ if (IExec->OpenDevice(SERIALNAME, 1, (struct IORequest *)SerialIO, 0)) /* Inform user that it could not be opened */ IDOS->Printf("Error: %s did not open\n",SERIALNAME); else { SerialIO->io_Baud = 38400; /* set 38400 baud */ SerialIO->IOSer.io_Length = 512; SerialIO->IOSer.io_Data = "#s\n"; SerialIO->IOSer.io_Command = CMD_WRITE; if (IExec->DoIO((struct IORequest *)SerialIO)) /* execute write */ IDOS->Printf("Write failed. Error - %ld\n", SerialIO->IOSer.io_Error); /* Close the serial device */ IDOS->Printf("Shutdown command given\n"); IExec->CloseDevice((struct IORequest *)SerialIO); } /* Delete the IORequest */ IExec->FreeSysObject(ASOT_IOREQUEST, SerialIO); } else /* Inform user that the IORequest could be created */ IDOS->Printf("Error: Could create IORequest\n"); /* Delete the message port */ IExec->FreeSysObject(ASOT_PORT, SerialMP); } else /* Inform user that the message port could not be created */ IDOS->Printf("Error: Could not create message port\n"); return 0; }
It can be shut down that way? Well what a strange setup!
Maybe you gave it too many commands. You set the write length to 512, then send a string of 3 characters. You can set length to -1 for a arbitrary string.
You may need to use the SDCMD_SETPARAMS to set the baud rate.
https://wiki.amigaos.net/wiki/Serial_Device
On X5000 this sequence is used (for querying temp, "shutdown", if working, should be same but "#s\n"):
BTW you can take a look at acpi.resource autodoc, maybe is valid for A1222 too.
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P