Name: U12.rawWriteRAM(Data, Address) Args: Data, a list of 4 bytes to write to memory. Address, the starting address to write to. Desc: Writes 4 bytes to the U12's internal memory. See section 5.13 of the User's Guide.
(self, Data, Address)
| 1531 | return returnDict |
| 1532 | |
| 1533 | def rawWriteRAM(self, Data, Address): |
| 1534 | """ |
| 1535 | Name: U12.rawWriteRAM(Data, Address) |
| 1536 | |
| 1537 | Args: Data, a list of 4 bytes to write to memory. |
| 1538 | Address, the starting address to write to. |
| 1539 | |
| 1540 | Desc: Writes 4 bytes to the U12's internal memory. See section 5.13 of |
| 1541 | the User's Guide. |
| 1542 | |
| 1543 | No default behavior, you must pass Data and Address. |
| 1544 | |
| 1545 | Returns: A dictionary with the following keys: |
| 1546 | DataByte0, the data byte at Address - 0 |
| 1547 | DataByte1, the data byte at Address - 1 |
| 1548 | DataByte2, the data byte at Address - 2 |
| 1549 | DataByte3, the data byte at Address - 3 |
| 1550 | |
| 1551 | Example: |
| 1552 | >>> import u12 |
| 1553 | >>> d = u12.U12() |
| 1554 | >>> print d.rawWriteRAM([1, 2, 3, 4], 0x200) |
| 1555 | {'DataByte3': 4, 'DataByte2': 3, 'DataByte1': 2, 'DataByte0': 1} |
| 1556 | """ |
| 1557 | command = [ 0 ] * 8 |
| 1558 | |
| 1559 | if not isinstance(Data, list) or len(Data) > 4: |
| 1560 | raise U12Exception("Data wasn't a list, or was too long.") |
| 1561 | |
| 1562 | Data.reverse() |
| 1563 | |
| 1564 | command[:len(Data)] = Data |
| 1565 | |
| 1566 | # 01010001 (Write RAM) |
| 1567 | bf = BitField() |
| 1568 | bf.bit6 = 1 |
| 1569 | bf.bit4 = 1 |
| 1570 | bf.bit0 = 1 |
| 1571 | command[5] = int(bf) |
| 1572 | |
| 1573 | command[6] = (Address >> 8) & 0xff |
| 1574 | command[7] = Address & 0xff |
| 1575 | |
| 1576 | self.write(command) |
| 1577 | results = self.read() |
| 1578 | |
| 1579 | if results[0] != int(bf): |
| 1580 | raise U12Exception("Expected ReadRAM response, got %s" % results[0]) |
| 1581 | |
| 1582 | if (results[6] != command[6]) or (results[7] != command[7]): |
| 1583 | receivedAddress = (results[6] << 8) + results[7] |
| 1584 | raise U12Exception("Wanted address %s got address %s" % (Address, receivedAddress)) |
| 1585 | |
| 1586 | returnDict = dict() |
| 1587 | |
| 1588 | returnDict['DataByte3'] = results[1] |
| 1589 | returnDict['DataByte2'] = results[2] |
| 1590 | returnDict['DataByte1'] = results[3] |
nothing calls this directly
no test coverage detected