?? commrs232.lst
字號:
635 /********************************************************************************************************
636 ** 函數名稱: void rs232_commright(void)
637 ** 功能描述:
638 ** 輸 入: 無
639 ** 輸 出: 無
640 ** 全局變量:
641 ** 調用模塊:
642 **
643 ** 作 者: 李偉
644 ** 日 期: 2008年12月20日
645 **-------------------------------------------------------------------------------------------------------
646 ** 修 改 人:
647 ** 日 期:
648 **-------------------------------------------------------------------------------------------------------
649 ********************************************************************************************************/
650 void rs232_commright(void)
651 {
652 1 rs_send_byte(0x7E); //報文頭
653 1 Rs232ComCalculChkSum = 0;
654 1 Rs232CommSendByteWithChk((uint8)(ModeSysConfig[8])); //BoardAddress地址范圍0~16
655 1 Rs232CommSendByteWithChk(Rs232CommCid); //CID 07
656 1 Rs232CommSendWordWithChk(0xA006); //LENTH
657 1 Rs232CommSendByteWithChk(0x01); //
658 1 Rs232CommSendWordWithChk(0x0001); //寫系數正確
659 1 Rs232ComCalculChkSum = (~Rs232ComCalculChkSum)+1;
660 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum>>8));
661 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum));
662 1 rs_send_byte(0x0D);
663 1 while (rs_f_TI == 0); //等待最后一個字節發送完畢
664 1 }
665 /********************************************************************************************************
666 ** 函數名稱: void rs232_commwrong(void)
667 ** 功能描述:
668 ** 輸 入: 無
669 ** 輸 出: 無
670 ** 全局變量:
671 ** 調用模塊:
672 **
673 ** 作 者: 李偉
674 ** 日 期: 2008年12月20日
675 **-------------------------------------------------------------------------------------------------------
C51 COMPILER V7.06 COMMRS232 10/30/2008 13:20:06 PAGE 12
676 ** 修 改 人:
677 ** 日 期:
678 **-------------------------------------------------------------------------------------------------------
679 ********************************************************************************************************/
680 void rs232_commwrong(void)
681 {
682 1 rs_send_byte(0x7E); //報文頭
683 1 Rs232ComCalculChkSum = 0;
684 1 Rs232CommSendByteWithChk((uint8)(ModeSysConfig[8])); //BoardAddress地址范圍0~16
685 1 Rs232CommSendByteWithChk(Rs232CommCid); //CID 07
686 1 Rs232CommSendWordWithChk(0xA006); //LENTH
687 1 Rs232CommSendByteWithChk(0x01); //
688 1 Rs232CommSendWordWithChk(0x0000); //寫系數錯誤
689 1 Rs232ComCalculChkSum = (~Rs232ComCalculChkSum)+1;
690 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum>>8));
691 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum));
692 1 rs_send_byte(0x0D);
693 1 while (rs_f_TI == 0);
694 1 }
695 /********************************************************************************************************
696 ** 函數名稱: void Comm_rs232_handshake(void)
697 ** 功能描述:
698 ** 輸 入: 無
699 ** 輸 出: 無
700 ** 全局變量:
701 ** 調用模塊:
702 **
703 ** 作 者: 李偉
704 ** 日 期: 2008年12月20日
705 **-------------------------------------------------------------------------------------------------------
706 ** 修 改 人:
707 ** 日 期:
708 **-------------------------------------------------------------------------------------------------------
709 ********************************************************************************************************/
710 void Comm_rs232_handshake(void)
711 {
712 1 rs_send_byte(0x7E); //報文頭
713 1 Rs232ComCalculChkSum = 0;
714 1 Rs232CommSendByteWithChk((uint8)(ModeSysConfig[8])); //BoardAddress地址范圍0~16
715 1 Rs232CommSendByteWithChk(Rs232CommCid); //CID 01
716 1 Rs232CommSendWordWithChk(0xA006); //LENTH
717 1 Rs232CommSendByteWithChk(0x01); //
718 1 Rs232CommSendWordWithChk(0x55AA);
719 1 Rs232ComCalculChkSum = (~Rs232ComCalculChkSum)+1;
720 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum>>8));
721 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum));
722 1 rs_send_byte(0x0D);
723 1 while (rs_f_TI == 0); //等待最后一個字節發送完畢
724 1 }
725 /********************************************************************************************************
726 ** 函數名稱: void Comm_rs232_readanalog(void)
727 ** 功能描述:
728 ** 輸 入: 無
729 ** 輸 出: 無
730 ** 全局變量:
731 ** 調用模塊:
732 **
733 ** 作 者: 李偉
734 ** 日 期: 2008年12月20日
735 **-------------------------------------------------------------------------------------------------------
736 ** 修 改 人:
737 ** 日 期:
C51 COMPILER V7.06 COMMRS232 10/30/2008 13:20:06 PAGE 13
738 **-------------------------------------------------------------------------------------------------------
739 ********************************************************************************************************/
740 void Comm_rs232_readanalog(void)
741 {
742 1 uint8 i;
743 1 rs_send_byte(0x7E); //報文頭
744 1 Rs232ComCalculChkSum = 0;
745 1 Rs232CommSendByteWithChk((uint8)(ModeSysConfig[8])); //BoardAddress地址范圍0~16
746 1 Rs232CommSendByteWithChk(Rs232CommCid); //CID 02
747 1 Rs232CommSendWordWithChk(0xF05C); //LENTH
748 1 Rs232CommSendByteWithChk(0x01); //
749 1 for(i = 0;i < 15;i++) //15只池電電壓
750 1 {
751 2 Rs232CommSendWordWithChk(CellVoltage[i]);
752 2 }
753 1 Rs232CommSendByteWithChk(0x02); //
754 1 for(i = 0;i < 9;i++) //15只電池溫度,1路環境溫度
755 1 {
756 2 CommSendByteWithChk(Temperature[i]);
757 2 }
758 1 Rs232CommSendByteWithChk(0x03);
759 1 Rs232CommSendWordWithChk(ChargeCurrent); //充電電流
760 1 Rs232CommSendWordWithChk(DisChargeCurrent); //放電電流
761 1 Rs232ComCalculChkSum = (~Rs232ComCalculChkSum)+1;
762 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum>>8));
763 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum));
764 1 rs_send_byte(0x0D);
765 1 while (rs_f_TI == 0); //等待最后一個字節發送完畢
766 1 }
767 /********************************************************************************************************
768 ** 函數名稱: void Comm_rs232_read_digital(void)
769 ** 功能描述:
770 ** 輸 入: 無
771 ** 輸 出: 無
772 ** 全局變量:
773 ** 調用模塊:
774 **
775 ** 作 者: 李偉
776 ** 日 期: 2008年12月20日
777 **-------------------------------------------------------------------------------------------------------
778 ** 修 改 人:
779 ** 日 期:
780 **-------------------------------------------------------------------------------------------------------
781 ********************************************************************************************************/
782 void Comm_rs232_read_digital(void)
783 {
784 1 rs_send_byte(0x7E); //報文頭
785 1 Rs232ComCalculChkSum = 0;
786 1 Rs232CommSendByteWithChk((uint8)(ModeSysConfig[8])); //BoardAddress地址范圍0~16
787 1 Rs232CommSendByteWithChk(Rs232CommCid); //CID 03
788 1 Rs232CommSendWordWithChk(0x501A); //LENTH
789 1
790 1 Rs232CommSendByteWithChk(0x01); //
791 1 Rs232CommSendByteWithChk(ComAlarmET ); //綜合告警
792 1 Rs232CommSendByteWithChk(ComAlarmVh0); //1~ 8只電池過壓告警
793 1 Rs232CommSendByteWithChk(ComAlarmVh1); //9~15只電池過壓告警
794 1 Rs232CommSendByteWithChk(ComAlarmVl0); //1~ 8只電池欠壓告警
795 1 Rs232CommSendByteWithChk(ComAlarmVl1); //9~15只電池欠壓告警
796 1 Rs232CommSendByteWithChk(ComAlarmScCTh); //1~15只電池充電過溫
797 1 Rs232CommSendByteWithChk(ComAlarmScCTl); //1~15只電池充電欠溫
798 1 Rs232CommSendByteWithChk(ComAlarmSDcTh); //1~15只電池放電過溫
799 1 Rs232CommSendByteWithChk(ComAlarmSDcTl); //1~15只電池放電欠溫
C51 COMPILER V7.06 COMMRS232 10/30/2008 13:20:06 PAGE 14
800 1 Rs232CommSendByteWithChk(ComTemperaSensor ); //1~ 8路溫度傳感器失效
801 1 Rs232CommSendByteWithChk(ComVoltageSensor0); //電壓傳感器失效
802 1
803 1 Rs232ComCalculChkSum = (~Rs232ComCalculChkSum)+1;
804 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum>>8));
805 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum));
806 1 rs_send_byte(0x0D);
807 1 while (rs_f_TI == 0); //等待最后一個字節發送完畢
808 1 }
809 /********************************************************************************************************
810 ** 函數名稱: void Comm_rs232_read_config(void)
811 ** 功能描述:
812 ** 輸 入: 無
813 ** 輸 出: 無
814 ** 全局變量:
815 ** 調用模塊:
816 **
817 ** 作 者: 李偉
818 ** 日 期: 2008年12月20日
819 **-------------------------------------------------------------------------------------------------------
820 ** 修 改 人:
821 ** 日 期:
822 **-------------------------------------------------------------------------------------------------------
823 ********************************************************************************************************/
824 void Comm_rs232_read_config(void)
825 {
826 1 uint8 i;
827 1 rs_send_byte(0x7E); //報文頭
828 1 Rs232ComCalculChkSum = 0;
829 1 Rs232CommSendByteWithChk((uint8)(ModeSysConfig[8])); //BoardAddress地址范圍0~16
830 1 Rs232CommSendByteWithChk(Rs232CommCid); //CID 05
831 1 Rs232CommSendWordWithChk(0x9052); //LENTH
832 1 Rs232CommSendByteWithChk(0x01); //電壓限值配置信息
833 1 for(i = 0;i < 9;i++)
834 1 {
835 2 Rs232CommSendWordWithChk(ModeSysConfig[i]);
836 2 }
837 1 Rs232CommSendByteWithChk(0x02); //溫度限值配置信息
838 1 for(i = 0;i < 12;i++)
839 1 {
840 2 Rs232CommSendByteWithChk(ModeTempCofing[i]);
841 2 }
842 1 Rs232CommSendByteWithChk(0x03); //系數
843 1 Rs232CommSendWordWithChk(CUK);
844 1 Rs232CommSendWordWithChk(CTK);
845 1 Rs232CommSendWordWithChk(OTK);
846 1 Rs232ComCalculChkSum = (~Rs232ComCalculChkSum)+1;
847 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum>>8));
848 1 Rs232CommSendByteWithoutChk((uint8)(Rs232ComCalculChkSum));
849 1 rs_send_byte(0x0D);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -