Example code to read device ID of MachXo2 with FTDI -JTAG
I'm not sure what MachXO2 device you are using, but I pulled the BSDL files of a couple of them at random. The IDCODE opcode appears to be '11100000', or 0xE0.

I'm also not sure what FTDI library you're using, but I'll assume you're using a FTDI FT2232H or similar that is capable of acting as a JTAG master via MPSSE functionality or similar. 

To read the IDCODE, you basically have to do the following:


JTAG Reset (put chain into known state) -- can be 5 TCKs with TMS held high
Load IR 0xE0 (8-bit IR Shift)
Perform a 32-bit DR shift to read out the IDCODE.


That's all there is to it -- I don't think the part needs to be in any particular state to support the IDCODE instruction. An ISC (IEEE 1532) instruction to read the USERCODE, possibly, but I also that's unlikely -- you should be able to read both with ease.

I Googled the function you're using (please add more detail to your questions in the future), and I think you're calling it incorrectly, since you appear to be writing to a data register. I think you want:

JTAG_WriteRead(fthandle, true, 8, 0xE0, 1, m_IRbuffer, m_numBytes, RUN_TEST_IDLE_STATE);
JTAG_WriteRead(fthandle, false, 32, 0x00000000, 4, m_DRbuffer, m_numBytes, RUN_TEST_IDLE_STATE);


Where m_IRbuffer is a buffer of size 1 byte, and m_DRbuffer is of size 4 bytes (32 bits), and m_numBytes can be a 1 byte char of some type. The first command should load 0xE0 into the IR. The second should shift in 32-bits of 0 into the IDCODE DR register, and you should get back the IDCODE in m_DRbuffer.

As an aside, if you're having trouble with this amount of low-level work, I would suggest using urjtag or a similar software library to read the information you need.